<?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 : Another &quot;generic&quot; question. Coming up with BaseRepository</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Another &quot;generic&quot; question. Coming up with BaseRepository</description>
  <pubDate>Wed, 13 May 2026 11:33:03 -700</pubDate>
  <lastBuildDate>Thu, 12 Jan 2012 09:13:14 -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=3210</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>Another &quot;generic&quot; question. Coming up with BaseRepository :   Fair enough. Yes, I was writing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12447#12447</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 12-Jan-2012 at 9:13am<br /><br />Fair enough. Yes, I was writing BusyOff on error and success, so that will help me make this async code even better..<div></div>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 09:13:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12447#12447</guid>
  </item> 
  <item>
   <title>Another &quot;generic&quot; question. Coming up with BaseRepository : One of the places I make use of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12446#12446</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 12-Jan-2012 at 9:11am<br /><br />One of the places I make use of the INotifyCompleted is with my Busy indicators. I might write some code like this:<br><br>Employee employee;<br>Busy.AddWatch();<br>Repository.GetEmployees(123, e =&gt; employee = e, ErrorHandler.HandleError)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .WhenCompleted(args =&gt; Busy.RemoveWatch());<br><br>This way it's saying, no matter what the result, success or fail, I want to make sure I am executing a certain action.<br><br>Without this, you are forced to write code that looks like this:<br><br>Busy.AddWatch();<br>Repository.GetEmployees(123, e =&gt;<br>{<br>&nbsp;&nbsp; employee = e<br>&nbsp;&nbsp; Busy.RemoveWatch();<br>},<br>(ex) =&gt;<br>{<br>&nbsp;&nbsp;&nbsp; ErrorHandler.HandleError(ex);<br>&nbsp;&nbsp;&nbsp; Busy.RemoveWatch();<br>});<br><br>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 09:11:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12446#12446</guid>
  </item> 
  <item>
   <title>Another &quot;generic&quot; question. Coming up with BaseRepository :   Actually, I am creating repository...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12444#12444</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 12-Jan-2012 at 8:43am<br /><br />Actually, I am creating repository per unit of work as you suggest. Entity type in this case represents primary entity and I use "includes" to get other related entities that I need. Each repository takes care of maintaining (CRUD) whole MVVM for Silverlight's view.<div>&nbsp;</div><div>Since you posted this sample, I was wondering why do I want to use <strong>INotifyCompleted</strong>? I find it easier to write code like below. When do I see benefit of using this interface? Simple Actions work well for me.</div><div><font color="#008000" size="2" face="C&#111;nsolas"><font color="#008000" size="2" face="C&#111;nsolas"><font color="#008000" size="2" face="C&#111;nsolas"></font></font></font>&nbsp;</div><p><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">public</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> </font></font><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">void</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> SaveAll(</font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Action</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"> onSuccess = </font></font><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">null</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">, </font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Action</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&lt;</font></font><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas"><font color="#2b91af" size="2" face="C&#111;nsolas">Exception</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">&gt; onFail = </font></font><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">null</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">)</font></font></p><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"></div><p>        {</font></p></font><p><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"> op = </font></font><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">this</font></font></font><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas">.EntityManager.SaveChangesAsync();</font></font></p><div><font size="2" face="C&#111;nsolas"><font size="2" face="C&#111;nsolas"></div><p>            op.OnComplete(onSuccess, onFail);</p><div></div><p>        }</p><div>&nbsp;</div><p>&nbsp;</p><p></font></font>&nbsp;</p>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 08:43:02 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12444#12444</guid>
  </item> 
  <item>
   <title>Another &quot;generic&quot; question. Coming up with BaseRepository : Rather than create a repository...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12443#12443</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 12-Jan-2012 at 8:33am<br /><br />Rather than create a repository per entity type, you may want to create one per unit-of-work. Otherwise you are going to be creating a lot more work for your self than needed.<br><br>By unit of work, I mean a related set of entities. An example might be employees, the primary entity is Employee, but you also may have contacts, addresses, and other such related entities.<br><br>This is what I do:<br><br><pre style="font-family:C&#111;nsolas;font-size:13;color:black;:white;"><span style="color:blue;">public</span>&nbsp;<span style="color:blue;">abstract</span>&nbsp;<span style="color:blue;">class</span>&nbsp;<span style="color:#2b91af;">RepositoryBase</span>&lt;T&gt;&nbsp;:&nbsp;<span style="color:#2b91af;">IRepository</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">where</span>&nbsp;T&nbsp;:&nbsp;<span style="color:#2b91af;">EntityManager</span>&nbsp;&nbsp;&nbsp;&nbsp;{<br>    }<br><br>then I would create an IEmployeeRepository that might look like this:<br><br><span style="color:blue;">public</span>&nbsp;<span style="color:blue;">interface</span>&nbsp;&nbsp;<span style="color:#2b91af;">IEmployeeRepository</span>&nbsp;:&nbsp;<span style="color:#2b91af;">IRepository</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">INotifyCompleted</span>&nbsp;GetEmployee(<span style="color:#2b91af;">Guid</span>&nbsp;employeeId,&nbsp;<span style="color:#2b91af;">Action</span>&lt;Employee&gt;&nbsp;onSuccess,&nbsp;<span style="color:#2b91af;">Action</span>&lt;<span style="color:#2b91af;">Exception</span>&gt;&nbsp;onFail);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">INotifyCompleted</span>&nbsp;GetEmployeeHistory(<span style="color:#2b91af;">Guid</span>&nbsp;employeeId,&nbsp;<span style="color:#2b91af;">Action</span>&lt;IEnumerable&lt;EmployeeHistory&gt;&gt;&nbsp;onSuccess,&nbsp;<span style="color:#2b91af;">Action</span>&lt;<span style="color:#2b91af;">Exception</span>&gt;&nbsp;onFail);&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span>&nbsp;<span style="color:blue;">class</span>&nbsp;<span style="color:#2b91af;">EmployeeRepository</span>&nbsp;:<span style="color:#2b91af;">RepositoryBase</span>&lt;MyEntities&gt;, <span style="color:#2b91af;">IEmployeeRepository</span>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">public</span>&nbsp;<span style="color:#2b91af;">INotifyCompleted</span>&nbsp;GetEmployee(<span style="color:#2b91af;">Guid</span>&nbsp;employeeId,&nbsp;<span style="color:#2b91af;">Action</span>&lt;Employee&gt;&nbsp;onSuccess,&nbsp;<span style="color:#2b91af;">Action</span>&lt;<span style="color:#2b91af;">Exception</span>&gt;&nbsp;onFail)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><span style="color:blue;">        public</span>&nbsp;<span style="color:#2b91af;">INotifyCompleted</span>&nbsp;GetEmployeeHistory(<span style="color:#2b91af;">Guid</span>&nbsp;employeeId,&nbsp;<span style="color:#2b91af;">Action</span>&lt;IEnumerable&lt;EmployeeHistory&gt;&gt;&nbsp;onSuccess,&nbsp;<span style="color:#2b91af;">Action</span>&lt;<span style="color:#2b91af;">Exception</span>&gt;&nbsp;onFail)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>DevForce Caliburn is a great framework to look at, I believe they have examples very similar to this.<br></pre><br>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 08:33:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12443#12443</guid>
  </item> 
  <item>
   <title>Another &quot;generic&quot; question. Coming up with BaseRepository :   Found solution.. Needed to...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12442#12442</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 12-Jan-2012 at 6:32am<br /><br />Found solution.. Needed to do <strong>where T: Entity, new()</strong><div></div><div></div><strong>var Entity = new T(); //</strong>works]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 06:32:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12442#12442</guid>
  </item> 
  <item>
   <title>Another &quot;generic&quot; question. Coming up with BaseRepository :   I&amp;#039;m finding that all...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12437#12437</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3210<br /><strong>Posted:</strong> 11-Jan-2012 at 9:30pm<br /><br />I'm finding that all my data repositories look alike and decided to try and make one base class with generics.<div>&nbsp;</div><div>However, I'm struggling with following piece of code(see screenshot). How do I create entity instance of &lt;T&gt; in this GetNew() method?</div><div>&nbsp;</div><div><img src="uploads/1264/gen1.PNG" height="364" width="772" border="0" /></div>]]>
   </description>
   <pubDate>Wed, 11 Jan 2012 21:30:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3210&amp;PID=12437#12437</guid>
  </item> 
 </channel>
</rss>