Is query to new added object possible in MS Entity Framework

Is there a way to query or just access newly added object (using ObjectContext.AddObject method) in Entity Framework? I mean situation when it is not yet saved to data store using SaveChanges

I understand that queries are translated to underlying SQL and executed against data store, and it don't have this new object yet. But anyway, I'm curious - if it is not oficially supported, maybe it is possible in theory. If it's not, how developer can deal with it? Manually track new objects and query them using Linq to objects?

The same question also applies to LinqToSql.


In EF, if you use this code, you have all the entities that are already loaded in the context (including newly added ones) :

context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified | EntityState.Unchanged).Select(o => o.Entity).OfType<YourObjectType>()

Need Your Help

Google Webmaster Tools won't index my site

indexing search-engine google-webmaster-tools

I discovered that my robots.txt file on my site is causing Google's Webmaster Tools to not index my site properly. I tried and removed just about everything from the file (using WordPress so it will

Javascript library for a “Universal Wishlist” type bookmark-button?

javascript bookmarks

Amazon has a Universal Wishlist button which can be added to the browser bookmarks bar, then pressed on any website and it sends the details of the page the user is currently looking at to Amazon. ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.