I am searching about update entity and find this result. And according to this answer, I need to find the changed properties in my attached entity. There is no MVC in my project and I cannot find changes in UI layer. How can I detect changes when I attach an object to a context?
Asked
Active
Viewed 214 times
1
-
1First of all, please try something yourself. Secondly, specify the senario. Where do you get values to update the entity? – Adil Mammadov Aug 01 '16 at 05:34
-
I am creating an web api and data are coming from client. this client may be any thing like android device, windows workstation, another web service or any thing else. I am looking for a solution. if i have a method i never add this question to stackoverflow. – Navid_pdp11 Aug 01 '16 at 05:41
-
"try something" does not mean you have solution. If your data is provided, what is difference between getting it from a client or from a view? You have data from client and you have data from database, just compare them – Adil Mammadov Aug 01 '16 at 05:45
-
please read the provided links. i wont get original data from data base. at last explicity. – Navid_pdp11 Aug 01 '16 at 05:48
-
1Do you receive PK from client? Why you won't get data from datbase? how you can determine if something has changed if you just have one entity? :) You have to either update all proeprties or get data from source and compare them. – Adil Mammadov Aug 01 '16 at 05:53
-
1if you do not get your original data and you can't use ChangeTracking, there is no way of knowing what properties have been changed (other than overwriting setters or something, but I do think EF internally calls setters). EF will do ChangeTracking by keeping an object in the graph and track the changes done to the entries in the DbSet and through Concurrency checking by the Concurrency tokens (mostly just PK). – DevilSuichiro Aug 01 '16 at 05:54
-
I prefer don't get original Entity because of server load. i see this answer and i think there is a way for detecting changes between Original and modified object. – Navid_pdp11 Aug 01 '16 at 05:57