<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Wrong SQL generated when using OrderBy and FirstOrDefault</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : Wrong SQL generated when using OrderBy and FirstOrDefault</description>
  <pubDate>Fri, 10 Apr 2026 22:17:18 -700</pubDate>
  <lastBuildDate>Tue, 18 Jun 2013 00:31:04 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=4177</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Wrong SQL generated when using OrderBy and FirstOrDefault : Ok, thanks kimj </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16448#16448</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4177<br /><strong>Posted:</strong> 18-Jun-2013 at 12:31am<br /><br />Ok, thanks kimj]]>
   </description>
   <pubDate>Tue, 18 Jun 2013 00:31:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16448#16448</guid>
  </item> 
  <item>
   <title>Wrong SQL generated when using OrderBy and FirstOrDefault : This appears to be an EF bug....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16447#16447</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 4177<br /><strong>Posted:</strong> 17-Jun-2013 at 1:59pm<br /><br />This appears to be an EF bug.  See <a href="http://entityframework.codeplex.com/workitem/196" target="_blank">http://entityframework.codeplex.com/workitem/196</a>.]]>
   </description>
   <pubDate>Mon, 17 Jun 2013 13:59:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16447#16447</guid>
  </item> 
  <item>
   <title>Wrong SQL generated when using OrderBy and FirstOrDefault : Hi,   I have an issue with the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16434#16434</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1623" rel="nofollow">kdev</a><br /><strong>Subject:</strong> 4177<br /><strong>Posted:</strong> 14-Jun-2013 at 2:57am<br /><br />Hi,<br /><br /><br />I have an issue with the generated SQL of a query using Orderby and FirstOrDefault.<br /><br />Let's say we have those 2 queries :<br /><br />var qry = from myentity in myquery.Where(d =&gt; d.Id == 348802)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  select myentity.mypropertynavigation.OrderByDescending(m =&gt; m.Debut).Where(m =&gt; m.Debut &lt;= DateTime.Today).FirstOrDefault();<br /><br />=&gt; It will correctly apply the ORDER BY and select the TOP(1)<br /><br />var qry = from myentity in myquery.Where(d =&gt; d.Id == 348802)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  select myentity.mypropertynavigation.OrderByDescending(m =&gt; m.Debut).FirstOrDefault(m =&gt; m.Debut &lt;= DateTime.Today);<br /><br />=&gt; It will ONLY select the TOP(1), the SQL contains no ORDER BY at all.<br /><br /><br />Is this a DF bug ?<br /><br />]]>
   </description>
   <pubDate>Fri, 14 Jun 2013 02:57:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4177&amp;PID=16434#16434</guid>
  </item> 
 </channel>
</rss>