<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Query me this...</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx</link><description>Explanation of two not-immediately-intuitive aspects of the EntityFramework's Query : delegation of queries to the target DB and identity resolution.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>system.data.objects dev guy : ???Local??? Queries</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx#9437062</link><pubDate>Sat, 21 Feb 2009 10:28:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9437062</guid><dc:creator>system.data.objects dev guy : ???Local??? Queries</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/dsimmons/archive/2009/02/21/local-queries.aspx"&gt;http://blogs.msdn.com/dsimmons/archive/2009/02/21/local-queries.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9437062" width="1" height="1"&gt;</description></item><item><title>A disappointing behaviour in local queries of EF</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx#9436627</link><pubDate>Sat, 21 Feb 2009 01:06:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9436627</guid><dc:creator>Ralph's Blog</dc:creator><description>&lt;p&gt;After an entity is created and added to the context it can not be queried unless it is saved to the database&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9436627" width="1" height="1"&gt;</description></item><item><title>re: Query me this...</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx#733399</link><pubDate>Thu, 31 Aug 2006 15:28:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:733399</guid><dc:creator>Daniel Simmons - MSFT</dc:creator><description>We don't really view the context as being the same as a transaction. &amp;nbsp;For that we have System.Transactions, and that is in fact a good strategy for queries that need to include not-yet-committed changes. &amp;nbsp;In fact, more discussion on the original thread that motivated me to write the above blog entry resulted in this comment that I made to that thread back on the forum (copied here because I don't think I can link directly to a comment in a thread on the forum--only to the entire thread):&lt;br&gt;&lt;br&gt;An unrelated discussion we were having today made me think of this thread, so I wanted to do a quick follow-up...&lt;br&gt;&lt;br&gt;There is one way we didn't talk about to query uncommitted changes: Using System.Transactions. &amp;nbsp;The support in this CTP is not the full thing we intend it to be before we release, but you can get it to work in some controlled scenarios today. &amp;nbsp;For example (copied from an email Pablo posted internally today, so hopefully he won't mind my plagarism):&lt;br&gt;&lt;br&gt;using(TransactionScope tx = new TransactionScope()) {&lt;br&gt;&lt;br&gt; &amp;nbsp; using(ObjectContext ctx = new ObjectContext(…)) {&lt;br&gt; &amp;nbsp; &amp;nbsp; var q = query…&lt;br&gt;&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; // …make some changes on the objects returned by “q”&lt;br&gt;&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; //…save changes without committing &lt;br&gt; &amp;nbsp; &amp;nbsp; ctx.SaveChanges();&lt;br&gt;&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; //…now do more queries, they’ll include the changes you flushed&lt;br&gt;&lt;br&gt;&lt;br&gt; &amp;nbsp; &amp;nbsp; //…now commit for real, or abort if don’t want the changes to be permanent&lt;br&gt; &amp;nbsp; &amp;nbsp; tx.Complete();&lt;br&gt; &amp;nbsp;}&lt;br&gt;}&lt;br&gt;&lt;br&gt; Please tread lightly in this area with this CTP, though. &amp;nbsp;There are definitely some pitfalls, but this should give you some other ideas to think about this topic in general.&lt;br&gt;&lt;br&gt;- Danny&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=733399" width="1" height="1"&gt;</description></item><item><title>re: Query me this...</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx#730204</link><pubDate>Tue, 29 Aug 2006 19:29:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:730204</guid><dc:creator>MatHobbs</dc:creator><description>Also, Hibernate has a FlushMode (see &lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://www.hibernate.org/hib_docs/v3/api/org/hibernate/FlushMode.html"&gt;http://www.hibernate.org/hib_docs/v3/api/org/hibernate/FlushMode.html&lt;/a&gt;) which provides some control over the 'precommit'/flush process when querying.&lt;br&gt;&lt;br&gt;Cheers,&lt;br&gt;-Matthew Hobbs&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=730204" width="1" height="1"&gt;</description></item><item><title>re: Query me this...</title><link>http://blogs.msdn.com/b/dsimmons/archive/2006/08/27/726559.aspx#729012</link><pubDate>Tue, 29 Aug 2006 00:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:729012</guid><dc:creator>Jaroslaw Kowalski - MSFT</dc:creator><description>Wouldn't it be possible to save dirty objects to the database automatically before running the query?&lt;br&gt;&lt;br&gt;I'm the author of Sooda - simple O/R mapper for .NET (&lt;a rel="nofollow" target="_new" href="http://www.sooda.org"&gt;http://www.sooda.org&lt;/a&gt;) and it supports a concept of &amp;quot;precommit&amp;quot; in this case.&lt;br&gt;&lt;br&gt;When executing a query, Sooda knows the tables/classes that the query accesses/depends on (by analyzing the WHERE clause) and issues a pre-commit of all unsaved objects of these classes. This way newly inserted objects will be properly returned by the upcoming SELECT statement. Final commit operation changes from INSERT to UPDATE on precommitted objects. Each Sooda transaction (which is equivalent to a context) is associated with an open database transaction, so partially written transactions can be cancelled if needed.&lt;br&gt;&lt;br&gt;This approach has some drawbacks and complexities (like how to deal with partially constructed objects which cannot be committed because of NULLs), but I believe it is a step towards making queries really easy to use and predictable.&lt;br&gt;&lt;br&gt;Would it be possible to have this implemented in EDM?&lt;br&gt;&lt;br&gt;BTW. I'll be joining Microsoft in October to work for ADO.NET vNext Team as SDET. Now that you've published the CTP, I can't wait to meet you all and play with the code as we'll be obviously working on a breakthrough technology.&lt;br&gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=729012" width="1" height="1"&gt;</description></item></channel></rss>