<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using a Command Execution Style Architecture with a Domain Model</title>
	<atom:link href="http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/</link>
	<description></description>
	<lastBuildDate>Wed, 08 May 2013 18:43:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Steve Powell</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-139</link>
		<dc:creator>Steve Powell</dc:creator>
		<pubDate>Fri, 26 Nov 2010 12:00:19 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-139</guid>
		<description>@Blair

We have an EntityBase base class which all our entities inherit from.  We use fluent nhibernate and map the ID column of the base class as follows (you also need a version column if you are assigning your own id value):
          Id(e =&gt; e.ID).GeneratedBy.Assigned();
          Version(x =&gt; x.Version).UnsavedValue(&quot;0&quot;);
 Then in the constructor of the entity base class we set the ID using a sequential GUID (quicker to access when querying db) using:

protected EntityBase()
        {
            ID = SequentialGuid();        
        }

        [DllImport(&quot;rpcrt4.dll&quot;, SetLastError = true)]
        static extern int UuidCreateSequential(out Guid guid);

        public static Guid SequentialGuid()
        {
            const int RPC_S_OK = 0;
            Guid g;
            if (UuidCreateSequential(out g) != RPC_S_OK)
                return Guid.NewGuid();
            else
                return g;
        }

The ID can be overwritten if required (as in the above case where you are asking a command to create an entity with a specific id)

As I say I will post more readable code on our blog once I get a chance...</description>
		<content:encoded><![CDATA[<p>@Blair</p>
<p>We have an EntityBase base class which all our entities inherit from.  We use fluent nhibernate and map the ID column of the base class as follows (you also need a version column if you are assigning your own id value):<br />
          Id(e => e.ID).GeneratedBy.Assigned();<br />
          Version(x => x.Version).UnsavedValue(&#8220;0&#8243;);<br />
 Then in the constructor of the entity base class we set the ID using a sequential GUID (quicker to access when querying db) using:</p>
<p>protected EntityBase()<br />
        {<br />
            ID = SequentialGuid();<br />
        }</p>
<p>        [DllImport("rpcrt4.dll", SetLastError = true)]<br />
        static extern int UuidCreateSequential(out Guid guid);</p>
<p>        public static Guid SequentialGuid()<br />
        {<br />
            const int RPC_S_OK = 0;<br />
            Guid g;<br />
            if (UuidCreateSequential(out g) != RPC_S_OK)<br />
                return Guid.NewGuid();<br />
            else<br />
                return g;<br />
        }</p>
<p>The ID can be overwritten if required (as in the above case where you are asking a command to create an entity with a specific id)</p>
<p>As I say I will post more readable code on our blog once I get a chance&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-138</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Wed, 24 Nov 2010 04:44:13 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-138</guid>
		<description>Anyone got any feedback on the discussion so far?</description>
		<content:encoded><![CDATA[<p>Anyone got any feedback on the discussion so far?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-137</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 15:50:05 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-137</guid>
		<description>Thought?</description>
		<content:encoded><![CDATA[<p>Thought?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-136</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 15:29:07 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-136</guid>
		<description>I thought as such. So to recap.

1. Web Page with field to create a new customer

2. MVC Controller action for Save

3. Create Command with details from form - Including a new GUID created in the controller and passed to the command object like the form arguements.

4. Get Handler for Command

5. Execute Command

6. Redirect to display new details on Say a Update page ie Controller Action Update in Get Mode.

I assume with NHibernate your using GUIDs for you Identity and no GENERATOR just GENERATOR ASSIGNED type in NHibernate.

Is this correct?

Thanks.</description>
		<content:encoded><![CDATA[<p>I thought as such. So to recap.</p>
<p>1. Web Page with field to create a new customer</p>
<p>2. MVC Controller action for Save</p>
<p>3. Create Command with details from form &#8211; Including a new GUID created in the controller and passed to the command object like the form arguements.</p>
<p>4. Get Handler for Command</p>
<p>5. Execute Command</p>
<p>6. Redirect to display new details on Say a Update page ie Controller Action Update in Get Mode.</p>
<p>I assume with NHibernate your using GUIDs for you Identity and no GENERATOR just GENERATOR ASSIGNED type in NHibernate.</p>
<p>Is this correct?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jcteague</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-135</link>
		<dc:creator>jcteague</dc:creator>
		<pubDate>Tue, 23 Nov 2010 15:21:10 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-135</guid>
		<description>As Stated earlier, the easiest way is to use a GUID for your id and pass that to you command.  At that point you just pass the guid onto the update command.

If you&#039;re using integers for your ids, than using a hi/lo implementation would be my next suggestion.

I would not recommend using an auto incrementing identity column in your database for your id (which I&#039;m guessing you&#039;re doing)  At that point, you&#039;re application no longer has control over the id generation.  Then you&#039;ll need to use a correlation identifier as Jimmy suggested.</description>
		<content:encoded><![CDATA[<p>As Stated earlier, the easiest way is to use a GUID for your id and pass that to you command.  At that point you just pass the guid onto the update command.</p>
<p>If you&#8217;re using integers for your ids, than using a hi/lo implementation would be my next suggestion.</p>
<p>I would not recommend using an auto incrementing identity column in your database for your id (which I&#8217;m guessing you&#8217;re doing)  At that point, you&#8217;re application no longer has control over the id generation.  Then you&#8217;ll need to use a correlation identifier as Jimmy suggested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-134</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 15:12:38 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-134</guid>
		<description>All I really want to know is how you handle create as mentioned earlier?</description>
		<content:encoded><![CDATA[<p>All I really want to know is how you handle create as mentioned earlier?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jcteague</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-133</link>
		<dc:creator>jcteague</dc:creator>
		<pubDate>Tue, 23 Nov 2010 14:54:52 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-133</guid>
		<description>@Blair, I will post some sample code as soon as I can.  I

On this application, we are not strictly following the CQS (though I with they looked more like what Jimmy is describing). I&#039;ll try to work up an example of both.

They run synchronously and return success or failure, any error messages and whatever data needs to be generated.
</description>
		<content:encoded><![CDATA[<p>@Blair, I will post some sample code as soon as I can.  I</p>
<p>On this application, we are not strictly following the CQS (though I with they looked more like what Jimmy is describing). I&#8217;ll try to work up an example of both.</p>
<p>They run synchronously and return success or failure, any error messages and whatever data needs to be generated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-132</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 14:46:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-132</guid>
		<description>What I would like to See is some code to get a feel for the comment I mentioned above.

Blair</description>
		<content:encoded><![CDATA[<p>What I would like to See is some code to get a feel for the comment I mentioned above.</p>
<p>Blair</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-131</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 14:17:40 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-131</guid>
		<description>Here is My Usage scenario.
1. Web Page with field to create a new customer
2. MVC Controller action for Save
3. Create Command with details from for
4. Get Handler for Command
5. Execute Command
6. Redirect to display new details on Say a Update page ie Controller Action Update in Get Mode.

If I do not know the Id of the newly saved customer how do I perform step 6?

Thats my point.
</description>
		<content:encoded><![CDATA[<p>Here is My Usage scenario.<br />
1. Web Page with field to create a new customer<br />
2. MVC Controller action for Save<br />
3. Create Command with details from for<br />
4. Get Handler for Command<br />
5. Execute Command<br />
6. Redirect to display new details on Say a Update page ie Controller Action Update in Get Mode.</p>
<p>If I do not know the Id of the newly saved customer how do I perform step 6?</p>
<p>Thats my point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blair</title>
		<link>http://lostechies.com/johnteague/2010/11/23/using-a-command-execution-style-architecture-with-a-domain-model/#comment-130</link>
		<dc:creator>Blair</dc:creator>
		<pubDate>Tue, 23 Nov 2010 14:13:01 +0000</pubDate>
		<guid isPermaLink="false">/blogs/johnteague/archive/2010/11/22/using-a-command-execution-style-architecture-with-a-domain-model.aspx#comment-130</guid>
		<description>If I have a MVC controller which is doing a save for example how do I know what the Id of the customer for example is. To have a Command Processor Does not need a MessageBus as I believe.

Do you use Assigned Identify in NHibernate then?</description>
		<content:encoded><![CDATA[<p>If I have a MVC controller which is doing a save for example how do I know what the Id of the customer for example is. To have a Command Processor Does not need a MessageBus as I believe.</p>
<p>Do you use Assigned Identify in NHibernate then?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
