How do I write a LINQ to SQL equivalent of:
INSERT INTO Table1 (field1, field2, field3)
SELECT field1, field2, field3
FROM Table2
WHERE (field1= @field1)
Thanks
How do I write a LINQ to SQL equivalent of:
INSERT INTO Table1 (field1, field2, field3)
SELECT field1, field2, field3
FROM Table2
WHERE (field1= @field1)
Thanks
If field of both the tables is same then, use
insert into table1 select * from table2 where table2.field1='xyz';
in place of:
Since you aren't returning any results, just use the low-level
DataContext.ExecuteCommand()
method:LINQ is a querying language, so it doesn't do updates or inserts. However -the LINQ to SQL entity object model has methods for handling CUD:
The real difference here is that it requires two separate SQL transactionsinstead of one - one to select, and one to insert.