How can you go about updating a record without having to select the data first in LINQ?
As you must first perform a linq select (obviously calls a SQL SELECT which is costly), change required properties, then perform SubmitChanges(). I wish to avoid this and just perform a SQL UPDATE, I already know the ID.
I haven’t tried it, but it looks as if you can do this with Attach:
Table(TEntity).Attach Method (TEntity, Boolean)
You set up the object in its updated state and pass it in, setting the boolean param to true. Of course, then you have to set all the fields, not just the ones you want to change.
If you only want to change a field or two, you can call SQL directly with the ExecuteCommand and ExecuteQuery methods on a DataContext object. You have to pass in the SQL as a string, and one argument for each parameter in the SQL. Note in particular how the SQL string has to be constructed: