LINQTOSQL at runtime
-
Hi ! I have a very odd problem. I am using LinqtoSql in my project in c#. , and what i do is i create a new table and set its column through sql server management studio express (2008 r2) , and I add a class file to the project(in visual studio) and using linq i do mapping of that table i made in Sql studio. e.g [column] public string firstname; [column] public string lname; etc etc. My question is , if i want to make a new table and add its column etc through the windows forms application in c# at runtime (using sql commands etc) , how can i use linq to automatically map the newly created table without manually editing the code? What should i do, i have to use LINQ to SQL.. PLZ HELP
-
Hi ! I have a very odd problem. I am using LinqtoSql in my project in c#. , and what i do is i create a new table and set its column through sql server management studio express (2008 r2) , and I add a class file to the project(in visual studio) and using linq i do mapping of that table i made in Sql studio. e.g [column] public string firstname; [column] public string lname; etc etc. My question is , if i want to make a new table and add its column etc through the windows forms application in c# at runtime (using sql commands etc) , how can i use linq to automatically map the newly created table without manually editing the code? What should i do, i have to use LINQ to SQL.. PLZ HELP
OK, so you create your DB table at run-time. But what about the class to which you are mapping the newly created table, is it created at run-time as well? If it is (i.e. you generate and compile the code, or emit CLR byte code) you could provide [column] attributes too: there is no "LINQ-specific magic" in .NET, so you can do nearly anything the compiler can.
-
OK, so you create your DB table at run-time. But what about the class to which you are mapping the newly created table, is it created at run-time as well? If it is (i.e. you generate and compile the code, or emit CLR byte code) you could provide [column] attributes too: there is no "LINQ-specific magic" in .NET, so you can do nearly anything the compiler can.
-
Thats the problem about classes . that how can i add new class file to the project and add attributes at runtime?