PrepAway - Latest Free Exam Questions & Answers

How can you at this point ensure that any changed made on the Product_details are saved in PassGuideDB as well

DRAG DROP
There is MS Visual Studio 2010 and MS .NET Framework 4 application PassGuideApp.
PassGuideApp connects to a MS SQL Server 2008 database PassGuideDB.
PassGuideApp uses EDU to model entities. These entities includes Product and
Product_details.
PassGuideApp is a multi-tier application.

You are going to do a search on the Product table. To make the search faster you deattach
Product_details.
The search is performed.
How can you at this point ensure that any changed made on the Product_details (by end
users for example) are saved in PassGuideDB as well.

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:

4 Comments on “How can you at this point ensure that any changed made on the Product_details are saved in PassGuideDB as well

  1. John Galt says:

    http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.attach%28v=vs.110%29.aspx

    Call Attach on the ObjectContext to attach the object to the object context. Do this when the object already exists in the data source but is currently not attached to the context.

    http://msdn.microsoft.com/en-us/library/dd487216%28v=vs.110%29.aspx

    The ApplyOriginalValues method is used to apply changes that were made to objects outside the ObjectContext, such as detached objects that are received by a Web service. The method copies the scalar values from the supplied object into the object in the ObjectContext that has the same key.




    0



    0
  2. John Galt says:

    Another helpful link, as I’m still not 100% clear on the difference between Current and Original values, and when to use each function:

    http://stackoverflow.com/questions/5576630/when-to-use-applyoriginalvalues-in-entity-framework-4

    Each entity loaded from the database keeps two sets of values – original (those loaded form DB) and current (those you are modifying). These two sets are hold in ObjectStateEntry. Usually each save is followed by accepting changes which takes current values and writes them to original values. If you know that you made changes to the entity outside of EF (for example by calling stored procedure with common ADO.NET EF) you can force EF to know about those changes without reloading the entity by using ApplyOriginalValues.




    0



    0

Leave a Reply