EntityFramework object cache. Getting already found objects

When Distortion Tracking is on, EF remembers all received objects. Is there some other way to tell EF not to query the DB for the object and search its local cache? I know that the GetObjectByKey method looks for an object in memory and only after that in the database.


source to share

1 answer

You can request ObjectStateManager


var entities = context.ObjectStateManager()
                      .GetObjectStateEntries(~EntityState.Detached) // All attached entities
                      .Where(e => !e.IsRelationship)
                      .Select(e => e.Entity)




All Articles