why Linq to sql can't track update information if we directly assign new object value to old .?

Viewed 285

I have the following code

Customer customer = (from x in db.Customers where x.CustomerID.Equals(cust.CustomerID.Value) select x).SingleOrDefault();

customer = newcustomer;
db.SubmitChanges();

by executing the above code I am able to get new data into the customer object, But by executing SubmitChanges() its can't update into the database.

I need to write following kind of mechanism to update value into database.

customer.CustomerName = "James";
customer.DisplayName = "Jimmy";

db.SubmitChanges();

Is there any suggestion for that ?

2 Answers
Related