LINQ Loop Function
-
Hi, I have a problem. I have a SQL database with 2 tables and in the same database I have created 2 new tables that basically takes the information from the first 2 tables. My question is this: How can I itterate throught the first tables and write that information to the new tables using LINQ to SQL?
Illegal Operation
-
Hi, I have a problem. I have a SQL database with 2 tables and in the same database I have created 2 new tables that basically takes the information from the first 2 tables. My question is this: How can I itterate throught the first tables and write that information to the new tables using LINQ to SQL?
Illegal Operation
try
MyDataContext dc = new MyDataContext();//the dbml file
var Table1 = from T in dc.YourTable1
select T;
foreach (var Row in Table1)
{
dc.ImportingTo Table2 = new dc.ImportingTo();
Table2.Field1 = Row.Field1;
Table2.Field2 = Row.Field2;
Table2.Field3 = Row.Field3;
Table2.Field4 = Row.Field4;//...etc.
dc.ImportingTo.InsertOnSubmit(Table2);
}
dc.SubmitChanges();I think this is the sintax! :-D if you have some problem, let me know! :thumbsup: