<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>backgroundmotion Forum Rss Feed</title><link>http://www.codeplex.com/backgroundmotion/Thread/List.aspx</link><description>backgroundmotion Forum Rss Description</description><item><title>New Post: UnitOfWork static gateway </title><link>http://www.codeplex.com/backgroundmotion/Thread/View.aspx?ThreadId=36983</link><description>&lt;div style="line-height: normal;"&gt;Hi,&lt;br&gt;
&lt;br&gt;
I am checking the code in the UnitOfWork class, which is is a static gateway to the current UnifOfWork instance. However, it is something that i can' understant the intention.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The implementation of UnitOfWork.Complete is &lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void Complete()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Current.Complete();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
and the Current property is&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private static IUnitOfWork Current&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return GetCurrent&amp;lt;IUnitOfWork&amp;gt;(); }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
where the GetCurrent&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static T GetCurrent&amp;lt;T&amp;gt;()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where T : IUnitOfWork&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ContextItemsBroker.GetItem&amp;lt;T&amp;gt;(CurrentContextKey);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
The CuurentContextKey is based on the private field _depth, which is a static field. First of all, there is no sycnhronization in this field, which is static. Interlock.Increment/Decrement would be more safe? When you have this code&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;using (UnitOfWork.Begin())&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contribution = UnmoderatedContributions&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Where(c =&amp;gt; c.Id == id)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .SingleOrDefault();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (contribution != null)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contribution.ApprovedBy = CurrentMember;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Repository&amp;lt;Contribution&amp;gt;.Save(contribution);&lt;br&gt;
&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UnitOfWork.Complete();&lt;br&gt;
&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
The UnitOfWork.Complete can be call a Complete in a UnitOfWork which is not the one returned in the Begin method. Is it supposed to be like this?&lt;br&gt;
&lt;br&gt;
Thanks in advance&lt;br&gt;
&lt;br&gt;
BFC&lt;br&gt;
&lt;/div&gt;</description><author>bfcamara</author><pubDate>Fri, 03 Oct 2008 15:26:59 GMT</pubDate><guid isPermaLink="false">New Post: UnitOfWork static gateway  20081003032659P</guid></item><item><title>NEW POST: Repository implementation</title><link>http://www.codeplex.com/backgroundmotion/Thread/View.aspx?ThreadId=24752</link><description>&lt;div style="line-height: normal;"&gt;Henrik,&lt;br&gt;
Just want to preface this post with the following statement: &amp;quot;It's a shame there are so many orphaned CodePlex projects&amp;quot;.&amp;nbsp; - end of grip.&lt;br&gt;
&lt;br&gt;
Ok, as I am not the original author, I can only make assumptions in my attempt to answer your questions.&lt;br&gt;
&lt;br&gt;
Regarding your questions (3,4); I believe the implementation of the Repository pattern is taking advantage of LINQ in the sense that, the repository interface is easily&lt;br&gt;
implemented due to LINQ functionality.&amp;nbsp; In essence the Repository code in this project is just a light wrapper around LINQ generated classes.&amp;nbsp; Therefore, it is more of a &lt;br&gt;
generic implementation.&amp;nbsp; Nothing has to extend the standard Repository methods, as the IRepository is a fully defined interface to provide all necessary functionality to&lt;br&gt;
fulfill the duties of a Repository.&lt;br&gt;
&lt;br&gt;
I think what you are seeking is an implementation base more on logic than a generic one that is used in this project.&amp;nbsp; You might want to take a look at the code here:&lt;br&gt;
http://www.codeplex.com/mvcsamples , it uses more of a logical based approach.&lt;br&gt;
&lt;br&gt;
- Good luck.&lt;br&gt;
&lt;div style="border-style:dotted none;border-color:rgb(170, 170, 170) -moz-use-text-color;border-width:0.1em medium;margin:1em 0em 2.5em 3em;padding:0.2em;font-style:italic"&gt;&lt;br&gt;
firefajter wrote:&lt;br&gt;
3. Have you considered a way of dealing with multiple repostiories at the same time?&lt;br&gt;
4. How would you suggest handling a specialized repository, for example a CustomerRepository extending the standard Repository methods.&lt;br&gt;
&lt;br&gt;
Thanks in advance&lt;br&gt;
/Henrik&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;</description><author>RBisch</author><pubDate>Mon, 09 Jun 2008 05:14:22 GMT</pubDate><guid isPermaLink="false">NEW POST: Repository implementation 20080609051422A</guid></item><item><title>NEW POST: Repository implementation</title><link>http://www.codeplex.com/backgroundmotion/Thread/View.aspx?ThreadId=24752</link><description>&lt;div class="wikidoc"&gt;
Hi, i've started to look att your implementation of repository/unit of work pattern for background motion and it seems great way of doing this. I want to use a similiar thing using the entity framework and have some questions that maybe you can help me answer.&lt;br /&gt; &lt;br /&gt;1. Since this was designed a year ago, is there anything you learned during this time of what worked out and if there is something you would have done differently today?&lt;br /&gt;2. Do you see any big problems of using this with entity framework (execept from the fact that model objects has to inherit from EntityObject)&lt;br /&gt;3. Have you considered a way of dealing with multiple repostiories at the same time?&lt;br /&gt;4. How would you suggest handling a specialized repository, for example a CustomerRepository extending the standard Repository methods.&lt;br /&gt; &lt;br /&gt;Thanks in advance&lt;br /&gt;/Henrik&lt;br /&gt;
&lt;/div&gt;</description><author>firefajter</author><pubDate>Wed, 26 Mar 2008 15:00:46 GMT</pubDate><guid isPermaLink="false">NEW POST: Repository implementation 20080326030046P</guid></item></channel></rss>