I want to update the only field of entity when I know entity Id.
Is it possible in LINQ to SQL without retrieving full entity (with all fields from DataContext that is overhead) ? Is it possible to create and attach entity to DataContext and mark the exact field(s) to synchronize on DataContext.SubmitChanges (or something like that)?
Thank you in advance!
You can always create a standard T-SQL statement and execute that against your data store:
With Linq-to-SQL itself, you cannot do this - it's basic assumption is that it always operates on the object, the whole object, and nothing but the object.
If you need to do this on a regular basis, one way would be to wrap it into a stored proc and add that stored proc to your data context as a method you can call on the data context.
Yes you can:
In your Dbml set UpdateCheck="Never" for all properties.
This will generate a single update statement without a select.
One caveat: if you want to be able to set Name to null you would have to initialize your foo object to a different value so Linq can detect the change:
If you want to check for a timestamp while updating you can do this as well:
You can refresh the object. This example will change the person's first name: