When entities are created and added to the context (but NOT saved to the DB) they do not appear in the query context.Orders.All().ToList(). Is there a way to return them in that query?
Thanks,
David Ribb
1 Answer, 1 is accepted
0
Zoran
Telerik team
answered on 14 Jul 2011, 08:40 AM
Hi David Ribb,
There is no API in the context object that can provide this functionality. However this functionality is there in the IObjectScope object which you can obtain through the context. If you have an IObjectScope instance, you can call scope.Transaction.Flush() in order to have those objects in your queries but still being able to Rollback them and persist them in the database.
You can obtain an IObjectScope instance if you write a partial class for you OpenAccessContext class like the following:
publicpartialYourContextClass
{
publicIObjectScope Scope
{
get{ returnthis.GetScope(); }
}
}
After adding your objects to you context, just call context.Scope.Transaction.Flush() and you will be able to have your added objects in your queries.Kind regards,
Zoran
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!