locked
DataServices and StateEntries RRS feed

  • Question

  • Hi,

    When we use datacontext in entity framework we have some ways to identify the state of modified/deleted/added entities, separate these entities if we would like so and also control concurrency, not justing receiving the concurrency error, but doing a refresh on the old values of a collection of entities.

    Using the proxy of ADO.NET Data Services, a dataservicecontext, I couldn't find any way to do these tasks. Is there some solution for that ?

    Thanks !

    []'s

    Dennes
    Dennes - Se resolveu, classifique a mensagem, por favor - [http://www.bufaloinfo.com.br] NOVO DVD Segurança no ASP.NET : http://www.bufaloinfo.com.br/LearingSeriesSegurancaASPNET2.asp
    Tuesday, April 14, 2009 6:23 AM

Answers

  • Hi ,
     The DataServiceContext also has a  similar concept about entity states .
     It has an Entities  collection which allows you to check for an entity's state.
     
    To Refresh an entity's value , you can call TryGetUri when the entity is tracked , then detach it .
    and subsequently call Execute<T> to refresh the value.

    Ex:
    Customer AlfKi = context.Customers.Where( c=>c.ID =="ALFKI").First();
    Uri entityURI = null;
    if( context.TryGetUri(AlfKi  , out entityURI ) ){
      context.Execute<Customer>( entityURI).First();
    }

    Here's an example of using this state information to check if the context has any pending changes

    DataServiceContext , Detect if there are pending changes
    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Tuesday, April 14, 2009 4:15 PM
    Moderator