Programatically creating a LINQ table from field names and types RRS feed

  • Question

  • Hi,

    I'm trying to create a table in an SQL Express database from within C# based on a config-file style input. So I'm tying to create a method that takes arguments about the table name, information regarding fields (name, type, length).
    Now normally I'd use LINQ based on a class that describes the data. But of course with a config file I don't know this in advance, so I can't just do Table<data_type> newtable = new Table<data_type>

    I tried creating a CREATE TABLE statement and giving it to the database directly but I couldn't get it to work in a way that worked well.

    I can't be the first person who's done this before and googling for information on this doesn't seem to yield any information. So I guess I'm missing something obvious. Help much appreciated!
    • Moved by Harry Zhu Thursday, March 5, 2009 9:44 AM relating to linq to sql (Moved from Visual C# General to LINQ to SQL)
    Saturday, February 28, 2009 7:02 PM