Data Developer Center >
Data Platform Development Forums
>
ADO.NET Entity Framework and LINQ to Entities
>
Submitting changes from client
Submitting changes from client
- I've been playing with ADO.NET EF for a couple days and so far I really like it. I have a Silverlight client that communicates with the server via WCF services. I can retrieve my entity objects (e.g., Orders) from the server (EF/SQL Server) and manipulate them in Silverlight. I'm also able to instantiate new Orders in Silverlight, send them up via a WCF service and persist them in SQL Server with something like
ds.AddToOrder(newOrderFromClient);
ds.SaveChanges();
Works great!
However, I haven't been able to figure out how to do updates. e.g., Let's say I retrieve an existing Order from the server, change an attribute of the order in Silverlight, then send the Order object back up to commit the change. Can't use AddToOrder. Guess I was hoping I could do something like
ds.UpdateOrder(changedOrderFromClient)
Can someone provide me a pointer that demonstrates the proper way to do this?
Many thanks.
Answers
- This topic deserves some additional discussion, and it comes up often enough that I decided to take a little while today to write a somewhat more complete answer in a post to my blog: http://blogs.msdn.com/dsimmons/archive/2009/04/09/building-n-tier-applications-with-the-ef-the-basics.aspx
- Danny
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byDaniel Simmons - MSFTOwnerFriday, July 03, 2009 4:49 AM
All Replies
- Hi *,
unfortunatelly there's no easy way. Look for multi-tier or N-tier keywords in forum and/or in efdesign blog.
Anyway if you're not dealing with changed associations and related objects, the easies way is to fetch the object from DB (to get the fresh data and have it in context), and then use ApplyPropertyChanges method. After this you'll be able to call SaveChanges and changes will be persisted in DB.
Jiri {x2} Cincura- Proposed As Answer byDaniel Simmons - MSFTOwnerThursday, April 09, 2009 5:10 AM
- This topic deserves some additional discussion, and it comes up often enough that I decided to take a little while today to write a somewhat more complete answer in a post to my blog: http://blogs.msdn.com/dsimmons/archive/2009/04/09/building-n-tier-applications-with-the-ef-the-basics.aspx
- Danny
This posting is provided "AS IS" with no warranties, and confers no rights.- Marked As Answer byDaniel Simmons - MSFTOwnerFriday, July 03, 2009 4:49 AM
- Hi *,
nice post Danny. :) All in one place together.
Jiri {x2} Cincura

