Is there a way to do an insert/select with Linq that translates to this sql:
INSERT INTO TableA (...)
SELECT ...
FROM TableB
WHERE ...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes @bzlm covered it first, but if you prefer something a bit more verbose:
I kind of prefer this from a review/maintenance point of view as I think its a bit more obvious what’s going on in the select.
In response to the observation by @JfBeaulac :
Please note that this will not generate the SQL shown – so far as I’m aware it’s not actually possible to generate directly using Linq (to SQL), you’d have to bypass linq and go straight to the database. Functionally its should achieve the same result in that it will perform the select and will then insert the data – but it will round-trip the data from the server to the client and back so may not be optimal for large volumes of data.