locked
How to get loaded entities RRS feed

  • Question

  • Is there a way to get all loaded entities on the server from the ObjectContext after making a query?

    I know that you can get Entities that are deleted and modified from the ObjectContext.ObjectStateManager but I would like to get a handle on just the retrieved entities if possible?


    Thanks in advance

    Wednesday, May 25, 2011 11:30 AM

Answers

  • What about this:

    ObjectContext.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Unchanged).Select(se => se.Entity)


    This returns the unchanged entities that are present in your ObjectContext. Typically, these are the entities that you queried. Of course, if you make changes to any of these, this statement no longer gives the result you're looking for.

    Thursday, May 26, 2011 5:26 PM

All replies

  • What about this:

    ObjectContext.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Unchanged).Select(se => se.Entity)


    This returns the unchanged entities that are present in your ObjectContext. Typically, these are the entities that you queried. Of course, if you make changes to any of these, this statement no longer gives the result you're looking for.

    Thursday, May 26, 2011 5:26 PM
  • I checked again and you're right. Thanks...

    Friday, May 27, 2011 8:42 AM