Context Tracking

4 posts, 0 answers
  1. Oliver Cox
    Oliver Cox avatar
    7 posts
    Member since:
    Nov 2009

    Posted 03 Jun 2010 Link to this post

    Hi,

    I downloaded the Silberlight Data Services example and begun to put together my own example but have encountered two issues:

    1. When editing a record the error below is thrown when calling context.AddToEntities(entity) method.
        "The context is already tracking the entity."
    2. When adding a new entity and moving from one cell to the next the error below is thrown when calling UpdateObject(entity)
        "The context is not currently tracking the entity."

    Now presumably I am doing someting wrong here or not accounting for some difference in the versions used in the example. Howver, my real question is how do I test if an entity is already added to the context? Is there for instance any way of testing for context.Entities.Conatins(entity)?

    Any help would be greatly appreciated.

    Thanks

    Oliver
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Jun 2010 Link to this post

    Hi Oliver Cox,

    You can use the TryGetEntity. If that method does not return anything then the entity is not being tracked and needs to be added. If however the method returns an entity then you will have call the update method rather than add it again since the entity is already being tracked by the context.

    Best wishes,
    Petar
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Iky
    Iky avatar
    2 posts
    Member since:
    May 2014

    Posted 29 Jan 2015 in reply to PetarP Link to this post

    Hi, i can't seem to find any documentation on the TryGetEntity method and I'm not too sure how i would use it. The entity I'm trying to update has a composite key.    

    Could you show me a basic usage example or direct me to Documentation?

    Thanks
  5. Ady
    Admin
    Ady avatar
    588 posts

    Posted 02 Feb 2015 Link to this post

    Hello Iky,

    The method is called 'TryGetObjectByKey'.
    If you tell me what you want to achieve maybe I could provide a more specific solution to your problem.

    Regards,
    Ady
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top