Lets say I have a File table with the column, “File_ID”.
How can I write a quick LINQ query/statement to set every “File_ID” in the File table to “1”?
I’m using LINQPad in Statement mode, but that doesn’t matter really.
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.
LINQ is for querying, not updating. The LINQ to SQL (and other data sources) models use a traditional object model of Add, Remove, getters and setters, and Update() to commit the changeset to the data backing.
What you are describing is simply iterating over all the record objects in your table collection, setting a property, and calling
Update(). It would be much faster and more efficient to do this in SQL with a singleUPDATEcommand.