<?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 : Adding optional includes on Repository&lt;&gt; WithIdAsync() method</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : Community Forum : Adding optional includes on Repository&lt;&gt; WithIdAsync() method</description>
  <pubDate>Fri, 10 Apr 2026 20:03:27 -700</pubDate>
  <lastBuildDate>Tue, 24 Apr 2012 12:27: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=3403</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>Adding optional includes on Repository&lt;&gt; WithIdAsync() method :   Oh BTW, congrats on the release....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13402#13402</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3403<br /><strong>Posted:</strong> 24-Apr-2012 at 12:27pm<br /><br />Oh BTW, congrats on the release.]]>
   </description>
   <pubDate>Tue, 24 Apr 2012 12:27:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13402#13402</guid>
  </item> 
  <item>
   <title>Adding optional includes on Repository&lt;&gt; WithIdAsync() method :    John,The idea behind WithIdAsync...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13401#13401</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3403<br /><strong>Posted:</strong> 24-Apr-2012 at 12:26pm<br /><br />John,<div>The idea behind WithIdAsync is that it always fetches the entity graph consistently per UoW type. In your specifc UoW you can use a subclass of Repository&lt;T&gt; and redefine the query you want it to use by overriding the GetKeyQuery method. I've done that in TempHire for example.<pre style="color: black; font-family: C&#111;nsolas;"> </pre><div>In places where you need to retrieve an entity by ID with a non-standard query, you would use FindAsync instead or actually define a different UoW type configured with a repository serving the purpose for that area of the application. Don't be shy about creating different UoW types optimized for the various areas and workflows of your application.</div></div><div>&nbsp;</div><div><pre style="color: black; font-family: C&#111;nsolas;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">class</span>&nbsp;<span>StaffingResourceRepository</span>&nbsp;:&nbsp;<span>Repository</span>&lt;<span>StaffingResource</span>&gt;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;StaffingResourceRepository(<span>IEntityManagerProvider</span>&lt;<span>TempHireEntities</span>&gt;&nbsp;entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;<span style="color: blue;">base</span>(entityManagerProvider)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">public</span>&nbsp;<span style="color: blue;">new</span>&nbsp;<span>TempHireEntities</span>&nbsp;EntityManager&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">get</span>&nbsp;{&nbsp;<span style="color: blue;">return</span>&nbsp;(<span>TempHireEntities</span>)&nbsp;<span style="color: blue;">base</span>.EntityManager;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">protected</span>&nbsp;<span style="color: blue;">override</span>&nbsp;<span>IEntityQuery</span>&nbsp;GetKeyQuery(<span style="color: blue;">params</span>&nbsp;<span style="color: blue;">object</span>&#091;&#093;&nbsp;keyValues)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue;">return</span>&nbsp;EntityManager.StaffingResources&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Where(r&nbsp;=&gt;&nbsp;r.Id&nbsp;==&nbsp;(<span>Guid</span>)&nbsp;keyValues&#091;0&#093;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Include(r&nbsp;=&gt;&nbsp;r.Addresses)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.Include(r&nbsp;=&gt;&nbsp;r.PhoneNumbers);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;}</pre><pre style="color: black; font-family: C&#111;nsolas;">&nbsp;</pre></div><span style="font-size:10px"><br /><br />Edited by mgood - 24-Apr-2012 at 12:34pm</span>]]>
   </description>
   <pubDate>Tue, 24 Apr 2012 12:26:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13401#13401</guid>
  </item> 
  <item>
   <title>Adding optional includes on Repository&lt;&gt; WithIdAsync() method :   I really like the WithIdAsync...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13397#13397</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1009" rel="nofollow">JohnBloom</a><br /><strong>Subject:</strong> 3403<br /><strong>Posted:</strong> 24-Apr-2012 at 10:46am<br /><br /><p>I really like the WithIdAsync function on the generic repository class. It has saved me from writing a bunch of little functions to load items by id. I noticed that FindAsync has the ability to add includes to it. There is often times when we want to include something when we load one item as well. Is this possible to do now or is this a feature request*?</p><p>*I realize that this question refers to the contrib library and if it is a feature I might be willing to jump in there and figure it out. As of now I have been head down moving through our transition to Cocktail** so I havent had time to figure the whole Git thing out. </p><p><br>**As a futher aside we just released our changes to our customers! Cocktail FTW!</p>]]>
   </description>
   <pubDate>Tue, 24 Apr 2012 10:46:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3403&amp;PID=13397#13397</guid>
  </item> 
 </channel>
</rss>