Consider the following code:
var Products_First = (from Entities.Product p in myContext.Product
select p);
Entities.Product newProdu
Properties of type ObjectQuery<T>
, like myContext.Product
, always query the DB. That's what they do.
In EF 4.1 you can use DbSet<T>.Local
to query memory.
In EF < 4.1 you would use:
ObjectContext.ObjectStateManager.GetObjectStateEntries(EntityState.Added).Select(o => o.Entity).OfType<Product>()