Answered by:
Save POCO class object using snapshot approach in EF 4

Question
-
I am using N-tier architecture (Silverlight client ,WCF service and EF4 in DAL ). Once data server by WCF to Silverlight client using EF (Code Only). It distroy ObjectContext and not keeping track changed by client. It is Disconnected approach. After change made by client to POCO (plain classes) sumbit to WCF and EF. At this time ObjectContext created and attached object but after calling SaveChanges. It dosn't save or update. If i use setModifed but it applies to all records in collection.
How to update selectively using EF 4. I don't want to use Self tracking framework because i use custom POCO and Code Only feature to map (configure) them ?
- Moved by Jonathan Aneja -- MSFT Thursday, June 24, 2010 11:08 PM (From:ADO.NET Entity Framework and LINQ to Entities (Pre-Release))
Wednesday, June 23, 2010 8:18 AM
Answers
-
Hello,
Welcome to EF forum!
The MSDN document: Building N-Tier Applications (Entity Framework) introduces several methods to update the entities. I have used one of them ObjectStateManager.ChangeObjectState to set the entity’s status as Modified in this thread, http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/cdc3868e-fae7-4ee7-bc00-74d9d3da620a.
Can you use the methods in the document in your scenario? If you have any questions, please feel free to let me know.
Have a nice weekend!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Proposed as answer by Michael Sun [MSFT]Microsoft employee Wednesday, June 30, 2010 1:34 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Friday, July 2, 2010 8:25 AM
Friday, June 25, 2010 1:18 AM -
I have used one of them ObjectStateManager.ChangeObjectState to set the entity’s status as Modified in this thread, http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/cdc3868e-fae7-4ee7-bc00-74d9d3da620a.
Yes. but what if I have a collection of objects but only one object is modified so I need to update only one object. If I use the method you sugguested I have to call "AsModified" on all object since we don't know which one is modified. How do I find which record is modified? so I can update that record only not all of them. see this link more info about this issue.http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/8cef35d5-3133-4efc-83e8-a4207057fb41
Updated
ApplyCurrentValues will fix the problem.
thanks,
ashraf
- Proposed as answer by Michael Sun [MSFT]Microsoft employee Wednesday, June 30, 2010 1:34 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Friday, July 2, 2010 8:25 AM
Friday, June 25, 2010 10:25 PM
All replies
-
Hello,
Welcome to EF forum!
The MSDN document: Building N-Tier Applications (Entity Framework) introduces several methods to update the entities. I have used one of them ObjectStateManager.ChangeObjectState to set the entity’s status as Modified in this thread, http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/cdc3868e-fae7-4ee7-bc00-74d9d3da620a.
Can you use the methods in the document in your scenario? If you have any questions, please feel free to let me know.
Have a nice weekend!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Proposed as answer by Michael Sun [MSFT]Microsoft employee Wednesday, June 30, 2010 1:34 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Friday, July 2, 2010 8:25 AM
Friday, June 25, 2010 1:18 AM -
I have used one of them ObjectStateManager.ChangeObjectState to set the entity’s status as Modified in this thread, http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/cdc3868e-fae7-4ee7-bc00-74d9d3da620a.
Yes. but what if I have a collection of objects but only one object is modified so I need to update only one object. If I use the method you sugguested I have to call "AsModified" on all object since we don't know which one is modified. How do I find which record is modified? so I can update that record only not all of them. see this link more info about this issue.http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/8cef35d5-3133-4efc-83e8-a4207057fb41
Updated
ApplyCurrentValues will fix the problem.
thanks,
ashraf
- Proposed as answer by Michael Sun [MSFT]Microsoft employee Wednesday, June 30, 2010 1:34 AM
- Marked as answer by Michael Sun [MSFT]Microsoft employee Friday, July 2, 2010 8:25 AM
Friday, June 25, 2010 10:25 PM -
Hi,
I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?
If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.
Have a nice day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.Tuesday, June 29, 2010 1:21 AM