<?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 : Query Single Entity</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Query Single Entity</description>
  <pubDate>Mon, 13 Apr 2026 19:48:13 -700</pubDate>
  <lastBuildDate>Mon, 16 May 2011 07:19:28 -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=2676</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>Query Single Entity : That worked. Thanks.   </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10696#10696</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1151" rel="nofollow">Randar</a><br /><strong>Subject:</strong> 2676<br /><strong>Posted:</strong> 16-May-2011 at 7:19am<br /><br />That worked.&nbsp; Thanks.]]>
   </description>
   <pubDate>Mon, 16 May 2011 07:19:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10696#10696</guid>
  </item> 
  <item>
   <title>Query Single Entity : Hi Randar,    Try .First()...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10681#10681</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2676<br /><strong>Posted:</strong> 13-May-2011 at 10:52am<br /><br /><DIV>Hi Randar,</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV></DIV><DIV>Try <EM>.First() </EM>or <EM>.</EM><EM>FirstOrDefault()</EM> instead of .<EM>ToList()</EM>.</DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Note that if you are working asynchronously (i.e. Silverlight) you will need to use <EM>.AsScalarAsync()</EM></DIV><DIV><EM></EM>&nbsp;</DIV><DIV><EM></EM></DIV><DIV></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> queryOp = _entityManager.GLAccountTypes</DIV><DIV><DIV></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Where(gla =&gt; gla.ID == ID)</DIV><DIV>.AsScalarAsync()</DIV><DIV>.First();</DIV></FONT></FONT></DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Also have in mind that in this case you will need to wait for the callback to be able to retrieve the result (i.e. <EM>queryOp</EM> does not hold the result)</DIV><DIV>&nbsp;</DIV><DIV>You will find more information about executing scalar queries async in the <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/async-immediate-executi&#111;n" target="_blank">DevForce Resource Center</A>.</DIV><DIV></DIV><DIV>In the <a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/query" target="_blank">DevForce Resource Center</A> you will also find valuable information about querying.</DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Silvio.</DIV><span style="font-size:10px"><br /><br />Edited by sbelini - 13-May-2011 at 10:55am</span>]]>
   </description>
   <pubDate>Fri, 13 May 2011 10:52:11 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10681#10681</guid>
  </item> 
  <item>
   <title>Query Single Entity : I am completely new to DevForce,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10679#10679</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1151" rel="nofollow">Randar</a><br /><strong>Subject:</strong> 2676<br /><strong>Posted:</strong> 13-May-2011 at 10:03am<br /><br />I am completely new to DevForce, so bear with me.<br><br>Simple question.&nbsp; What is the best practice for getting a single entity, based on a primary key, in this case ID.&nbsp; Everything in DF seems to get back a collection and then you have to get the first item in the collection.&nbsp; Is there a shortcut for getting a single entity?&nbsp; Here is what I am using right now:<br><br>Dim emg As EntityManager_GL = New EntityManager_GL()<br>Dim atQuery = From accountType In emg.GLAccountTypes<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Where accountType.ID = ID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select accountType<br><br>Dim itemList = atQuery.ToList() ' TODO: Is there a better way?<br><br>If (Not itemList Is Nothing And itemList.Count &gt; 0) Then<br>&nbsp;&nbsp;&nbsp; Dim item = itemList(0) ' Get the first item in the list<br><br>&nbsp;&nbsp; &nbsp;' Map it to the current record<br>&nbsp;&nbsp;&nbsp; With item<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_ID = .ID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_CompanyID = .CompanyID<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_Description = .Description<br>&nbsp;&nbsp;&nbsp; End With<br>End If<br><br>p.s. I haven' tested this code because I am having issues with my web service.&nbsp; But that just seems to be my environment.<br><br>]]>
   </description>
   <pubDate>Fri, 13 May 2011 10:03:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2676&amp;PID=10679#10679</guid>
  </item> 
 </channel>
</rss>