0

If I map my Domain objects to linq Entities will I now not be able to track changes when saving my domain objects? So for any change in my model that i wish to make, once I map the object to linq entities for submission to db, all object values will be submitted to the db by linq since it it goes through a mapping first? Or would the object tracking here still be utilized?

2 Answers 2

1

Depends on the O/R mapper you're using. You're referring to entity framework which doesn't do any change tracking inside the entity and therefore it needs help from you when you re-attach an entity which previously was fetched from the db (so it knows it's not new).

Sign up to request clarification or add additional context in comments.

1 Comment

linq to sql has tracking. But when i map domain back to the entity it considers everything changed even if it was not. how to tell entity its not a real change or vice versa?
1

Here's an article from microsoft about CRUD operations in multi-tiered environments (similiar issues to your Domain mapping scenario).

Check out the Update - With Complete Entities for the way to do change tracking yourself.

There's another technique, where you attach the entity as unmodified, and then .Refresh() with Keep Current Values - replacing the original. This would allow you to Insert/Update/Do Nothing as appropriate at the cost of a database roundtrip.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.