<?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 : Implementing Domain Driven Design with Devforce</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2012 : Implementing Domain Driven Design with Devforce</description>
  <pubDate>Tue, 12 May 2026 23:27:25 -700</pubDate>
  <lastBuildDate>Fri, 12 Jul 2013 23:16:47 -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=4205</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>Implementing Domain Driven Design with Devforce : Marcel,Thank you so much.We really...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16594#16594</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 12-Jul-2013 at 11:16pm<br /><br />Marcel,&nbsp;<div><br></div><div>Thank you so much.&nbsp;</div><div>We really had a hard time to let our brain get open for the idea of a <b>default EntityManager</b>.&nbsp;</div><div><br></div><div>We <b>could't imagine</b>, thats this would work.&nbsp;</div><div><br></div><div>With this idea in mind, we are now capable to implement the Domain Driven Design within our Application and keep the Models much cleaner.</div><div><br></div><div>Really</div><div><br></div><div>Thank You... looks all so easy, but makes a big difference for us.</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Fri, 12 Jul 2013 23:16:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16594#16594</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Again, the EntityManager has no...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16592#16592</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> 4205<br /><strong>Posted:</strong> 12-Jul-2013 at 9:43am<br /><br />Again, the EntityManager has no direct relationship to any of your models. Remember what I said before. Any EntityManager type can query any of your models. So, you simply create a repository for the entity type you need. It doesn't matter what type of EntityManager you hand to the repository.<div><br></div><div><div>&nbsp; &nbsp; &#091;Export(typeof(IResourceMgtUnitOfWork)), PartCreationPolicy(CreationPolicy.NonShared)&#093;</div><div>&nbsp; &nbsp; public class ResourceMgtUnitOfWork : UnitOfWork, IResourceMgtUnitOfWork</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;ImportingConstructor&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public ResourceMgtUnitOfWork(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(RequiredCreationPolicy = CreationPolicy.NonShared)&#093; IEntityManagerProvider&lt;TempHireEntities&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; entityManagerProvider,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(AllowDefault = true)&#093; IGlobalCache globalCache = null)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : base(entityManagerProvider)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressTypes = new GlobalCacheRepository&lt;AddressType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; States = new GlobalCacheRepository&lt;State&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PhoneNumberTypes = new GlobalCacheRepository&lt;PhoneNumberType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RateTypes = new GlobalCacheRepository&lt;RateType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResourceFactory = new StaffingResourceFactory(entityManagerProvider, AddressTypes, PhoneNumberTypes);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResources = new StaffingResourceRepository(entityManagerProvider);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Search = new StaffingResourceSearchService(StaffingResources);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">VehicleRepository = new Repository&lt;EntityTypeFromAnotherModel&gt;(</span><span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">entityManagerProvider</span><span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">);</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div><br></div><div>Better yet, just forget about the subclassed EntityManager and go with the out-of-the-box EntityManager.</div><div><br></div><div><div>&nbsp; &nbsp; &#091;Export(typeof(IResourceMgtUnitOfWork)), PartCreationPolicy(CreationPolicy.NonShared)&#093;</div><div>&nbsp; &nbsp; public class ResourceMgtUnitOfWork : UnitOfWork, IResourceMgtUnitOfWork</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;ImportingConstructor&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public ResourceMgtUnitOfWork(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(RequiredCreationPolicy = CreationPolicy.NonShared)&#093; IEntityManagerProvider&lt;<font color="#ff0000">EntityManager</font>&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; entityManagerProvider,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(AllowDefault = true)&#093; IGlobalCache globalCache = null)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : base(entityManagerProvider)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressTypes = new GlobalCacheRepository&lt;AddressType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; States = new GlobalCacheRepository&lt;State&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PhoneNumberTypes = new GlobalCacheRepository&lt;PhoneNumberType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RateTypes = new GlobalCacheRepository&lt;RateType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResourceFactory = new StaffingResourceFactory(entityManagerProvider, AddressTypes, PhoneNumberTypes);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResources = new StaffingResourceRepository(entityManagerProvider);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Search = new StaffingResourceSearchService(StaffingResources);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">VehicleRepository = new Repository&lt;EntityTypeFromAnotherModel&gt;(</span><span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">entityManagerProvider</span><span style="line-height: 1.4; font-family: 'Courier New', Courier, mono; white-space: pre; : rgb251, 251, 253;">);</span></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div><br></div><div><div>&nbsp; &nbsp; public class EntityManagerProviderFactory</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;Export&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public IEntityManagerProvider&lt;<font color="#ff0000">EntityManager</font>&gt; TempHireEntityManagerProvider</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; get</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var provider = new EntityManagerProvider&lt;<font color="#ff0000">EntityManager</font>&gt;();</div><div>#if FAKESTORE</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; provider.Configure(config =&gt; config.WithConnectionOptions(ConnectionOptions.Fake.Name));</div><div>#endif</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return provider;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div>]]>
   </description>
   <pubDate>Fri, 12 Jul 2013 09:43:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16592#16592</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce :  Thanks again for your detailed...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16587#16587</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 12-Jul-2013 at 3:43am<br /><br />Thanks again for your detailed answere.<div><br></div><div>We have started to rip out our addidtional Service layers and try to implement the Different Models with one EntityManagers.</div><div><br></div><div>But we are having a hard time, to understand how you would implement different Models within the UnitOfWork, because you have already injected a specific IEntityManagerProvider&lt;T&gt;, that has only Access to one Model.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &#091;Export(typeof(IResourceMgtUnitOfWork)), PartCreationPolicy(CreationPolicy.NonShared)&#093;</div><div>&nbsp; &nbsp; public class ResourceMgtUnitOfWork : UnitOfWork, IResourceMgtUnitOfWork</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;ImportingConstructor&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public ResourceMgtUnitOfWork(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(RequiredCreationPolicy = CreationPolicy.NonShared)&#093; IEntityManagerProvider&lt;<font color="#ff0000">TempHireEntities</font>&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; entityManagerProvider,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#091;Import(AllowDefault = true)&#093; IGlobalCache globalCache = null)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : base(entityManagerProvider)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddressTypes = new GlobalCacheRepository&lt;AddressType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; States = new GlobalCacheRepository&lt;State&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PhoneNumberTypes = new GlobalCacheRepository&lt;PhoneNumberType&gt;(entityManagerProvider, globalCache);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RateTypes = new GlobalCacheRepository&lt;RateType&gt;(entityManagerProvider, globalCache);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResourceFactory = new StaffingResourceFactory(entityManagerProvider, AddressTypes, PhoneNumberTypes);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaffingResources = new StaffingResourceRepository(entityManagerProvider);</div><div><font color="#ff0000"><span ="apple-tab-span"="" style="white-space: pre;">	</span>&nbsp; </font>&nbsp; VehicleRepository = new VehicleRepository(<span style="line-height: 1.4;">entityManagerProvider&lt;</span><span style="color: rgb255, 0, 0; line-height: 1.4;"><font color="#ff0000">needToQueryAnotherModel</font>&gt;)</span></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Search = new StaffingResourceSearchService(StaffingResources);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div></pre></td></tr></table></div><div><br></div><div>We dont see a way to extend the interfaces, an tell on repository to Query agains another Model.</div><div><br></div><div>Or do we need to Write our own Repository to override some methods.</div><div><br></div><div>We see our self chained to <u>one EntityManager with one Model.&nbsp;</u></div><span style="font-size:10px"><br /><br />Edited by cypher - 12-Jul-2013 at 3:43am</span>]]>
   </description>
   <pubDate>Fri, 12 Jul 2013 03:43:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16587#16587</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : I&amp;#039;m not sure what you find...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16584#16584</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> 4205<br /><strong>Posted:</strong> 11-Jul-2013 at 12:06pm<br /><br />I'm not sure what you find difficult about the GetQuery syntax. In Cocktail it's even abstracted in the Repository class. You rarely have to use GetQuery directly as fetching data should always occur through a repository which can optimize the fetching strategy based on the use case. Maybe you can elaborate some more.&nbsp;<div><br></div><div>The same entity in multiple models comes up regularly. The reality generally is that if you have the same entity in different models they are used for different purposes. It is recommended that only one model is used to create/edit that entity and the other models simply use it for read-only purposes and should only map the relevant parts. If multiple models edit that same entity the application is lacking a clear separation of concerns.&nbsp;<div><br></div><div>For example in the Customer case you may have a model for customer maintenance. It has the full customer entity mapped, so you can create new customers and edit existing customers. Then you may have an Invoice model for example. In the invoice model the customer is used for a different purpose. As far as an invoice is concerned you probably only need the customer Id, name, billing address and payment information, so the customer entity in that model should only map those parts. Then you may have a shipping model. In that model the customer probably only needs id, name and shipping address. The billing address and payment information is irrelevant for shipping purposes. It helps if you don't use the same name for the Customer entity in every model. For example you could call it Customer, InvoiceCustomer and ShippingCustomer to clearly delineate their use.&nbsp;</div><div><br></div><div>As far as the unit of work goes you would have the appropriate repositories in there so that if you do need to retrieve the full customer entity in the Invoice module for example you can always do so by customer id. Keeping the majority of your logic/rules external to the entities in services and perhaps a rules engine will make it easier to deal with multiple representations of the same entity.</div></div><div><br></div><div>To really show this in an example application would take a lot of time and complexity and every situation is slightly different. Our professional services organization has written or helped writing very large applications with DDD. This topic is now crossing over into architecture consulting and that's beyond the scope of this forum. Perhaps I can convince you to get in touch with our professional services organization, who could help you come up with the right approach for your situation.&nbsp;</div>]]>
   </description>
   <pubDate>Thu, 11 Jul 2013 12:06:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16584#16584</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Hi Marcel,thanks for Sharing this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16576#16576</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 11-Jul-2013 at 12:27am<br /><br />Hi Marcel,<div><br></div><div>thanks for Sharing this informations.</div><div><br></div><div>For me the EntityManager was clearly the generated Context... like it is in EntityFramework.&nbsp;</div><div><br></div><div>We have already found the documentation:&nbsp;<a href="http://drc.ideablade.com/devforce-2012/bin/view/&#068;ocumentati&#111;n/many-models-per-manager" target="_blank">http://drc.ideablade.com/devforce-2012/bin/view/Documentation/many-models-per-manager</a></div><div><br></div><div>but we are having a difficulty to live with the Syntax of get query, especially, if you have on entity in multimpe models (e.g. The Customer in the samples above).</div><div><br></div><div>A Codesample how to deal with this situation in conjuntion with cocktail would really help us understand your way of implementing DDD.&nbsp;</div><div><br></div><div>Thanks in advance for your advices to the community.&nbsp;</div>]]>
   </description>
   <pubDate>Thu, 11 Jul 2013 00:27:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16576#16576</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Cypher,This is all good as far...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16564#16564</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> 4205<br /><strong>Posted:</strong> 10-Jul-2013 at 9:22am<br /><br /><span style=": rgb251, 251, 253;">Cypher</span>,<div>This is all good as far as DDD goes. I'm very familiar with DDD. I think the confusion comes from the fact that you are thinking of the EntityManager as the context. The EntityManager is at a higher level. It represents the business process by extension of the unit of work. The relationships are as follows:</div><div><br></div><div>Business Process 1---1 UoW 1---1 EntityManager 1---n DbContext(s)</div><div><br></div><div>For each distinct business process in your app you assemble a unit of work with the right repos, factories, services etc. and that's where you implement all the logic for your business process. The UoW will use one EntityManager, which in turn may use multiple DbContexts if the business process is cross domain.&nbsp;</div><div><br></div><div>You don't even necessarily need to subclass EntityManager. You can use the out of the box EntityManager class as is.&nbsp;</div><span style="font-size:10px"><br /><br />Edited by mgood - 10-Jul-2013 at 9:24am</span>]]>
   </description>
   <pubDate>Wed, 10 Jul 2013 09:22:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16564#16564</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Hi Marcel,i&amp;#039;m glad you ask.We...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16563#16563</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 10-Jul-2013 at 6:37am<br /><br />Hi Marcel,<div><br></div><div>i'm glad you ask.</div><div><br></div><div>We are really trying to Implement the DDD approach with a Bounded (DB) Context (Context = EntityManager).</div><div>We are working in an Enterprise Environment with a Database with more than 100 Entitys and some complex dependencies.</div><div><br></div><div>To break this complexity a little bit up, we are trying to have a bounded Context.</div><div><br></div><div>Here are some Samples of the&nbsp;<a href="http://pluralsight.com/training/Courses/TableOfC&#111;ntents/efarchitecture" target="_blank">Entity Framework in the Enterprise Pluralsight Course of Julie Lermann</a></div><div><br></div><div><img src="uploads/1600/7-10-2013_3-21-49_PM.png" height="740" width="969" border="0" /><br></div><div><img src="uploads/1600/7-10-2013_3-22-43_PM.png" height="730" width="973" border="0" /><br></div><div><img src="uploads/1600/7-10-2013_3-23-41_PM.png" height="733" width="1003" border="0" /><br></div><div>With this information in mind... se split our implementation of cocktail into three major layers.</div><div><br></div><div><img src="uploads/1600/VIS_Architecture_overview_2.png" height="720" width="960" border="0" /><br></div><div>and implemented several Domain Models with the corresponding Domain Services:</div><div><br></div><div><img src="uploads/1600/VIS_Architecture_overview_1.png" height="720" width="960" border="0" /><br></div><div>Now you can see, that we are dealing with several EntityManagers (Contextes) from within on Module. But only during the Save Process, we need Access on the different Models and Managers.</div><div><br></div><div>Putting this logic all into on Big Unit of Work, is not really a Domain Driven Design implementation. But at some point, we will not come around to have some duplication. But for now, we where able to live with the different EntityManagers and get them together, wenn the Business Processes starts.&nbsp;</div><div><br></div><div>E.g. Saleresults need to be captured, after the user has chanded some trigger informaion on the Main Entity in the Vehicle.&nbsp;</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Wed, 10 Jul 2013 06:37:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16563#16563</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : I&amp;#039;m still having difficulty...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16561#16561</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> 4205<br /><strong>Posted:</strong> 09-Jul-2013 at 11:59am<br /><br />I'm still having difficulty with your using of multiple EntityManagers. In order for any entities to be saved properly, they must be in the cache of the EntityManager that is performing the save. I'm not clear on your extension method above and on what EntityManager you are calling it as well as why you need multiple EntityManagers for this in the first place.<div><br></div><div>The one thing that stands out from your approach is the fact that you can't perform any asynchronous calls in your logic if you place it inside of the EntityManagerDelegate. Sooner or later one of your business rules may need to query for additional data. At that point you have to query synchronous which is gonna negatively affect the responsiveness and performance of your app.&nbsp;</div><div><br></div><div>The proper approach for adding logic during a save would be to override CommitAsync in the unit of work, where you can perform synchronous as well as asynchronous logic before the save is executed.</div>]]>
   </description>
   <pubDate>Tue, 09 Jul 2013 11:59:44 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16561#16561</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Hi Marcel,we only need to create...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16558#16558</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 09-Jul-2013 at 7:49am<br /><br /><div>Hi Marcel,</div><div><br></div><div>we only need to create the entitys, if the user decides to save.</div><div>Then we start&nbsp;<span style="line-height: 1.4;">Business Processes, that update, modify and delete enititys, that are not directly related to our unit of work. But depending on the Changes in our Unit of Work, we have to&nbsp;</span><span style="line-height: 1.4;">modify different tables.</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;">Therefore we are trying to let this complexity out of the UoW and implement this Workflow logic, only if the user has changed some entitys, that need to start a business process.&nbsp;</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;">We found out, that we can still have this seperated out into different Models and Managers and Create, Modify or update Entitiys with different EntityManagers. We just have to add the Changes not only to newly created EntityManager, we also need to tell the&nbsp;</span><span style="line-height: 1.4;">EntitySavingEventArgs to save the changes.</span></div><div><span style="line-height: 1.4;"><br></span></div><div><span style="line-height: 1.4;">Currently we are dealing with business processes, that that check for changes in the UoW and start a Business Process, that maybe need to add entitys with another EntityManager and Model. Therefore we have created the Extension Method, where the&nbsp;</span><span style="line-height: 1.4;">EntitySavingEventArgs are now filled with more than one EntityManager, but still get saved with&nbsp;</span><span style=": rgb251, 251, 253; line-height: 1.4;">distributed transaction (because our models have different connection strings).</span></div><div><br></div><table width="99%"><tr><td><pre class="BBcode"><div><div>namespace Common.Extensions</div><div>{</div><div>&nbsp; &nbsp; using IdeaBlade.EntityModel;</div><div><br></div><div>&nbsp; &nbsp; public static class EntityManagerExtensions</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; #region Public Methods and Operators</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &nbsp; &nbsp; Attaches a new Entity from within the Save Interceptor</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/summary&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;param name="manager"&gt;The manager.&lt;/param&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;param name="entity"&gt;The entity to be added, updated or deleted.&lt;/param&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;param name="savingEventArgs"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &nbsp; &nbsp; The &lt;see cref="EntitySavingEventArgs" /&gt; instance containing the event data.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; /// &lt;/param&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public static void AddEntity(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this EntityManager manager,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; object entity,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EntitySavingEventArgs savingEventArgs)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; manager.AddEntity(entity);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; savingEventArgs.Entities.Add(entity);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; #endregion</div><div>&nbsp; &nbsp; }</div><div>}</div></div><div></pre></td></tr></table></div><div><br></div><div><br></div><div>Right now it perfectly works, and in the UoW, we really care only about "simple" changes.&nbsp;</div><div>But in the Save interceptor, we verify, what has been changed, to start additional business processes.</div><div><br></div><div>here is a sample of our Code</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>if (args.Entities.OfType&lt;Vehicle&gt;()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Any())</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var vehicle = args.Entities.OfType&lt;Vehicle&gt;()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Select(x =&gt; x)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .FirstOrDefault();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckDamageFlags(vehicle);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckNewUnitFlag(vehicle);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Composition.GetInstance&lt;IChangeRemarketingChannelAndSaleRelation&gt;()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.Start(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vehicle,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;args)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.Execute();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args.Cancel = !CheckIsVinUnique(context, vehicle);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div><div></pre></td></tr></table></div><div><br></div><div><br></div><div>Do you think, this is an anti pattern?</div>]]>
   </description>
   <pubDate>Tue, 09 Jul 2013 07:49:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16558#16558</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : On a releated note, I get the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16555#16555</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> 4205<br /><strong>Posted:</strong> 08-Jul-2013 at 1:16pm<br /><br />On a releated note, I get the feeling that you are incorrectly using the EntityManagerDelegate. The kind of business logic you describe belongs into services and factories on the unit of work.&nbsp;]]>
   </description>
   <pubDate>Mon, 08 Jul 2013 13:16:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16555#16555</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Just to add to what Greg wrote....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16554#16554</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> 4205<br /><strong>Posted:</strong> 08-Jul-2013 at 1:04pm<br /><br />Just to add to what Greg wrote. The EntityManager is the transaction boundary on the client. Everything that needs to be saved as part of the same transaction needs to be created in the same EntityManager. This extends to the UoW in Cocktail. The UoW has a one-to-one relationship to an EntityManager.&nbsp;<div><br></div><div>You can have multiple EntityManagerDelegates per EntityManager type on the client if you want to split up some of the logic, but all logic needs to operate on the same&nbsp;EntityManager&nbsp;instance.</div><div><br></div><div>In the SaveInterceptor on the server you can create/modify additional entities and have them save as part of the same transaction.</div><div><br></div><div>As a final note, an EntityManager has no direct relationship to a particular model. Any EntityManager can query any entity regardless in what model the entity is defined. You can even mix entities from different models and physical databases in the same EntityManager and they all get saved in the same transaction and if necessary the transaction gets escalated to a distributed transaction.</div><div><br></div><div>You should think of the EntityManager as a bucket for all your current changes that you gonna save together. This point is really driven home with the UoW pattern. Don't think of the EntityManager in any way associated to a particular model.&nbsp;</div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Mon, 08 Jul 2013 13:04:33 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16554#16554</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : Cypher,  I think you are mixing...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16550#16550</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=579" rel="nofollow">gregweb</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 07-Jul-2013 at 6:04pm<br /><br />Cypher,<br /><br />I think you are mixing up the SaveIntercepteor, and the EntityManagerDelegate.<br /><br />The SaveInterceptor is on the server, while the EntityManagerDelegate is on the client.  But they are completely different classes and uses.<br /><br />In the OnSaving, there is no reason you couldn't just new up a different EntityManager if you need to work with it.<br /><br />For example, in OnSaving:<br /><br />var salesEntityManager = new SalesEntityManager;<br /><br />var salesEntity = new SalesEntity();<br />salesEntityManager.AddEntity(salesEntity);<br />salesEntityManager.SaveChanges();<br /><br />But this is not recommended as it is completely outside the transaction and the whole Cocktail Unit-Of-Work Pattern.<br /><br />I too run into the issue of wanting different entity managers for different parts of the App, but if there are relations, it becomes difficult to work with the separate managers just like the case here. <br /><br />If you look at TempHireEntities, and your using CodeFirst, it's just a list of EntityQueries.  Maybe you could just add the query you need to get it all in the same EntityManager and then you would get a transaction.  Haven't tested this, but I don't see why it wouldn't work.<br /><br />Hope this helps.<br />Greg ]]>
   </description>
   <pubDate>Sun, 07 Jul 2013 18:04:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16550#16550</guid>
  </item> 
  <item>
   <title>Implementing Domain Driven Design with Devforce : We are trying to Implement DDD...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16512#16512</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1600" rel="nofollow">cypher</a><br /><strong>Subject:</strong> 4205<br /><strong>Posted:</strong> 01-Jul-2013 at 1:42am<br /><br />We are trying to Implement DDD with Devforce 2012.<div><br></div><div>So we have several Domain Models (e.g. Customer, Sales, Finance) and several EntityManagers for each Domain Model.</div><div><br></div><div>Now we are facing the situation, where we need to update one Manager from within another manager with the EntityManagerDelegate SaveInterceptor.&nbsp;</div><div><br></div><div>What we are trying to achive, is to seperate out the related Business rules and Validations into each Manager and Model, but at the Save Interceptor, we need to update more than one EntityManager (e.g. if a customer is created, the Sale Manager need to create some empty tables with the related customer). This has to be a transactional Save.</div><div><br></div><div>Here is a little Sample:</div><div><span style=": rgb251, 251, 253;"><table width="99%"><tr><td><pre class="BBcode"></span></div><div><div>&nbsp; &nbsp;public class CustomerContextDelegates : EntityManagerDelegate&lt;CustomerContext&gt;</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public override void OnSaved(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;CustomerContext&nbsp;context,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EntitySavedEventArgs args)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (args.CompletedSuccessfully) EventFns.Publish(new SavedMessage(args.Entities));</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; public override void OnSaving(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;CustomerContext&nbsp;context,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EntitySavingEventArgs args)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (args.Entities.OfType&lt;Customer&gt;().Any())</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var sut = args.Entities.OfType&lt;Customer&gt;().Select(x =&gt; x).FirstOrDefault();<span style="line-height: 1.4;">&nbsp; &nbsp; &nbsp; &nbsp;</span></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var businessProcess = new CreateNewCustomer(sut, context, args);</div></div><div><br></div><div>//TODO: Here we need to create a SalesContext Manager and ensure, that both managers get saved transactional.</div><div>}</div><div>}</div><div><span style=": rgb251, 251, 253;"></pre></td></tr></table></span></div><div><span style=": rgb251, 251, 253;"><br></span></div><div><span style=": rgb251, 251, 253;">Is there a way to create a new EntityManager in the SaveInterceptor and ensure, that both EntityManagers gets saved in an Transaction?</span></div><div><span style=": rgb251, 251, 253;"><br></span></div><div>(e.g. only insert a customer in the CustomerEntityManager if the SalesEntityManager has created the corresponding empty Sales entitys)</div><div><br></div><div><br></div><div><span style=": rgb251, 251, 253;"><br></span></div><div><span style=": rgb251, 251, 253;"><br></span></div><div><span style=": rgb251, 251, 253;"><br></span></div>]]>
   </description>
   <pubDate>Mon, 01 Jul 2013 01:42:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=4205&amp;PID=16512#16512</guid>
  </item> 
 </channel>
</rss>