<?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 : EntityServerException with children reference</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : EntityServerException with children reference</description>
  <pubDate>Sat, 11 Apr 2026 23:38:48 -700</pubDate>
  <lastBuildDate>Thu, 01 May 2008 18:51:09 -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=794</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>EntityServerException with children reference : Well ... we do keep pushing the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2924#2924</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> 794<br /><strong>Posted:</strong> 01-May-2008 at 6:51pm<br /><br />Well ... we do keep pushing the date for Beta2 off, don't we? <img src="http://www.ideablade.com/forum/smileys/smiley1.gif" height="17" width="17" border="0" align="absmiddle" alt="Smile" />&nbsp; <DIV>&nbsp;</DIV><DIV>Right now, we're looking at mid-May (yes, 2-3 weeks from now).</DIV>]]>
   </description>
   <pubDate>Thu, 01 May 2008 18:51:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2924#2924</guid>
  </item> 
  <item>
   <title>EntityServerException with children reference :   Awesome. Thanks, Kim. When...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2923#2923</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=293" rel="nofollow">philpastor</a><br /><strong>Subject:</strong> 794<br /><strong>Posted:</strong> 01-May-2008 at 5:42pm<br /><br /><DIV></DIV><DIV>&nbsp;</DIV><DIV>Awesome. Thanks, Kim. When are those bits going to be released? :)</DIV><span style="font-size:10px"><br /><br />Edited by philpastor - 01-May-2008 at 5:44pm</span>]]>
   </description>
   <pubDate>Thu, 01 May 2008 17:42:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2923#2923</guid>
  </item> 
  <item>
   <title>EntityServerException with children reference : Oh, you&amp;#039;re not doing anything...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2921#2921</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> 794<br /><strong>Posted:</strong> 01-May-2008 at 2:26pm<br /><br />Oh, you're not doing anything wrong, it looks like we do have a bug.<DIV>&nbsp;</DIV><DIV>What's happening is that when the first query executed for a given type (like Customer) is one which forces immediate execution, i.e., a query using First, Max, Count, etc., then we're not correctly doing some initialization required to handle related entities.&nbsp; When we attempt to retrieve the related entities and none are returned we get the unhandled sequence exception you see.&nbsp; You've found a unique case, since if you'd first queried for a Customer using deferred execution the error wouldn't have occurred; also if you'd done a First() query on a customer having orders the problem wouldn't have surfaced.</DIV><DIV>&nbsp;</DIV><DIV>The good news&nbsp;-&nbsp;due to some refactoring we've already done in query processing -&nbsp; is that this problem&nbsp;has already been fixed in our latest bits.&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>For your purposes right now, I guess the workaround could be to try to avoid using "immediate execution" type of queries.&nbsp; In this case, a ToList() followed by a First(), like this:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#006633>&nbsp;&nbsp;&nbsp; aManager.Customers.Where(c =&gt; c.CustomerID == "PARIS").ToList().First();</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#000000>would avoid the problem.</FONT></DIV><DIV>&nbsp;</DIV><DIV>Thanks for bringing this to our attention.</DIV>]]>
   </description>
   <pubDate>Thu, 01 May 2008 14:26:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2921#2921</guid>
  </item> 
  <item>
   <title>EntityServerException with children reference : Kim,  Thank you for the response.  This...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2919#2919</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=293" rel="nofollow">philpastor</a><br /><strong>Subject:</strong> 794<br /><strong>Posted:</strong> 01-May-2008 at 11:15am<br /><br /><DIV></DIV>Kim,<DIV>&nbsp;</DIV><DIV>Thank you for the response.</DIV><DIV>&nbsp;</DIV><DIV>This may be my lack of understanding of LINQ, but using the tutorial and the Northwind database I executed the following commands:</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#006633>aManager = new DomainModel.Manager();</FONT></DIV><DIV><FONT color=#006633>DomainModel.Customer aCustomer = aManager.Customers.Where(c =&gt; c.CustomerID == "PARIS").First();</FONT></DIV><DIV><FONT color=#006633>System.Diagnostics.Debug.WriteLine(string.Format("Customer Id: {0} - Number of Orders: {1}", aCustomer.CustomerID, aCustomer.Orders.Count));</FONT></DIV><P><P><FONT size=2></P><DIV></DIV>This results in the exception. In this example the customer "PARIS" has no orders. Does the First() method&nbsp;sever the&nbsp;ability to lazy load?&nbsp;</P><DIV>If I change it to the following, then it works just fine:</DIV><DIV><FONT color=#0000ff size=2>aManager = new DomainModel.Manager();</DIV><DIV><DIV>var query = aManager.Customers.Where(c =&gt; c.City.Length == 5);</DIV><DIV>foreach (DomainModel.Customer aCustomer in query)</DIV><DIV>{</DIV><DIV>Console.WriteLine(string.Format("Customer Id: {0} - Number of Orders: {1}",aCustomer.CustomerID, aCustomer.Orders.Count));</DIV><DIV>}</DIV><P></FONT><FONT size=2></P><DIV></DIV></FONT></FONT></DIV>]]>
   </description>
   <pubDate>Thu, 01 May 2008 11:15:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2919#2919</guid>
  </item> 
  <item>
   <title>EntityServerException with children reference : How are you accessing the child...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2917#2917</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> 794<br /><strong>Posted:</strong> 01-May-2008 at 8:27am<br /><br /><P>How are you accessing the child collection?&nbsp; Something simple like:</P><DIV>&nbsp;&nbsp; var list = Company.Employees;</DIV><DIV>&nbsp;</DIV><DIV>or more complex:</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp; var list = Company.Employees.Skip(2).Take(2);</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>These should actually work, but we need a little more information to help uncover the problem.&nbsp;&nbsp; Are you able to recreate the problem using any of the tutorials?</DIV>]]>
   </description>
   <pubDate>Thu, 01 May 2008 08:27:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2917#2917</guid>
  </item> 
  <item>
   <title>EntityServerException with children reference :  I am receiving an &amp;#034;EntityServerException:...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2911#2911</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=293" rel="nofollow">philpastor</a><br /><strong>Subject:</strong> 794<br /><strong>Posted:</strong> 30-Apr-2008 at 10:15am<br /><br /><DIV>&nbsp;</DIV><DIV>I am receiving an "EntityServerException: Sequence contains no elements" when I try to navigate to an association property that does not have any children.</DIV><DIV>&nbsp;</DIV><DIV>I have a Company object that contains a collection of Employees. I expected that if there were no employees I would receive an empty List&lt;Employee&gt; collection. But instead I received the exception. What is the correct way to determine whether or not this collection is empty?</DIV><DIV>&nbsp;</DIV><DIV>Just as a note, if I create an employee in the database, then the Employee is returned in the association (so the model is wired up correctly).</DIV><DIV>&nbsp;</DIV><DIV>Phil</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 30 Apr 2008 10:15:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=794&amp;PID=2911#2911</guid>
  </item> 
 </channel>
</rss>