Linq To SQL Attach / Refresh Entity Object

In Linq To Sql, when I update one of my entities, Faculty, I create a new instance of Faculty object, then initialize some properties with user supplied values.

If I attach this new object to the entity set and submit the changes, then the properties I have not set take the default for any data type.

How do I update the new object so that properties that have been set retain their values, and properties that have not been set receive values ​​from the database?

thanks

+11


a source to share


2 answers


You tried

context.Refresh(RefreshMode.OverwriteCurrentValues, faculty);



after submitting the changes, where context

is your linq2sql datacontext and faculty

is the object you want to update?

+15


a source


How do I get an object from the database, then change the corresponding values, and then send an update?



0


a source







All Articles