Insert/Select with Linq-To-SQL -


is there way insert/select linq translates sql:

insert tablea (...) select ... tableb ... 

yes @bzlm covered first, if prefer bit more verbose:

// dc = datacontext, assumes tablea contains items of type var toinsert = b in tableb                ...                select new                 {                    ...                };  tablea.insertallonsubmit(toinsert); dc.submitchanges(); 

i kind of prefer review/maintenance point of view think bit more obvious what's going on in select.


in response observation @jfbeaulac :

please note will not generate sql shown - far i'm aware it's not possible generate directly using linq (to sql), you'd have bypass linq , go straight database. functionally should achieve same result in perform select , insert data - round-trip data server client , may not optimal large volumes of data.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -