<?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: State Pattern, Enumeration Class and Fluent NHibernate (Oh my!)</title>
	<atom:link href="http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/</link>
	<description></description>
	<lastBuildDate>Tue, 16 Mar 2010 18:16:58 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Migrating to Fluent NHibernate - Jimmy Bogard - Los Techies : Blogs about software and anything tech!</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50867</link>
		<dc:creator>Migrating to Fluent NHibernate - Jimmy Bogard - Los Techies : Blogs about software and anything tech!</dc:creator>
		<pubDate>Wed, 02 Dec 2009 02:08:10 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50867</guid>
		<description>[...] Configure custom NHibernate types for your own custom types (like the Enumeration class) [...]</description>
		<content:encoded><![CDATA[<p>[...] Configure custom NHibernate types for your own custom types (like the Enumeration class) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don Cote</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50100</link>
		<dc:creator>Don Cote</dc:creator>
		<pubDate>Tue, 03 Nov 2009 15:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50100</guid>
		<description>&lt;blockquote cite=&quot;#commentbody-50079&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-50079&quot; rel=&quot;nofollow&quot;&gt;Richard Cirerol&lt;/a&gt; :&lt;/strong&gt;
Don,
I am curious to know why you would return a list of statuses on one instance. 
&lt;/blockquote&gt;

My particular situation has to do with business units being allowed to use different invoicing event types -- just stuck w/ the Status example from above.

By the way - thanks for the help!  Your code example worked out great.</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-50079"><p>
<strong><a href="#comment-50079" rel="nofollow">Richard Cirerol</a> :</strong><br />
Don,<br />
I am curious to know why you would return a list of statuses on one instance.
</p></blockquote>
<p>My particular situation has to do with business units being allowed to use different invoicing event types &#8212; just stuck w/ the Status example from above.</p>
<p>By the way &#8211; thanks for the help!  Your code example worked out great.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Cirerol</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50096</link>
		<dc:creator>Richard Cirerol</dc:creator>
		<pubDate>Tue, 03 Nov 2009 14:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50096</guid>
		<description>We are using a custom user type for regular enums, but this Enumeration did not seem to conform to the user type conventions.  Can you post a sample of a custom user type to encapsulate this problem?  I would be very interested.</description>
		<content:encoded><![CDATA[<p>We are using a custom user type for regular enums, but this Enumeration did not seem to conform to the user type conventions.  Can you post a sample of a custom user type to encapsulate this problem?  I would be very interested.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Cromwell</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50093</link>
		<dc:creator>Ryan Cromwell</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50093</guid>
		<description>&lt;a href=&quot;#comment-50071&quot; rel=&quot;nofollow&quot;&gt;@Richard Cirerol &lt;/a&gt; 
My sticking point is with the FNH.  Do you use the property backing field for ease rather than a custom UserType?</description>
		<content:encoded><![CDATA[<p><a href="#comment-50071" rel="nofollow">@Richard Cirerol </a><br />
My sticking point is with the FNH.  Do you use the property backing field for ease rather than a custom UserType?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Cirerol</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50079</link>
		<dc:creator>Richard Cirerol</dc:creator>
		<pubDate>Tue, 03 Nov 2009 02:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50079</guid>
		<description>Don,

I am curious to know why you would return a list of statuses on one instance.  But, I guess I would serialize the values to a delimited string if needed.  Something along the lines of this:

protected string _statusList;
public IList&lt;MyStatus&gt; StatusList
{
get
   { 
     var list = new List&lt;MyStatus&gt;();
     _statusList.Split(new[]{&quot;;&quot;},StringSplitOptions.None).ToList()
     .ForEach(x=&gt;list.Add(Enumeration.FromValue&lt;MyStatus&gt;(x)); 
     return new List&lt;MyStatus&gt;{list};
   }
set{ _statusList=string.Join(&quot;;&quot;,value.Select(x=&gt;x.Value).ToArray());}
}

and the fluent mapping would be:

public void Override(AutoMapping&lt;MyProgress&gt; mapping)
{
  mapping.Map(x =&gt; x.StatusList)
    .CustomType(typeof(string))
    .Access.CamelCaseField(Prefix.Underscore);
}

You could also serialize to JSON or XML before persisting the value. The idea is that the protected member is what you would store, while the public member is what you want to interact with.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Don,</p>
<p>I am curious to know why you would return a list of statuses on one instance.  But, I guess I would serialize the values to a delimited string if needed.  Something along the lines of this:</p>
<p>protected string _statusList;<br />
public IList<mystatus> StatusList<br />
{<br />
get<br />
   {<br />
     var list = new List</mystatus><mystatus>();<br />
     _statusList.Split(new[]{&#8221;;&#8221;},StringSplitOptions.None).ToList()<br />
     .ForEach(x=>list.Add(Enumeration.FromValue</mystatus><mystatus>(x));<br />
     return new List</mystatus><mystatus>{list};<br />
   }<br />
set{ _statusList=string.Join(&#8221;;&#8221;,value.Select(x=>x.Value).ToArray());}<br />
}</p>
<p>and the fluent mapping would be:</p>
<p>public void Override(AutoMapping<myprogress> mapping)<br />
{<br />
  mapping.Map(x => x.StatusList)<br />
    .CustomType(typeof(string))<br />
    .Access.CamelCaseField(Prefix.Underscore);<br />
}</p>
<p>You could also serialize to JSON or XML before persisting the value. The idea is that the protected member is what you would store, while the public member is what you want to interact with.</p>
<p>Hope that helps.</myprogress></mystatus></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don Cote</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50074</link>
		<dc:creator>Don Cote</dc:creator>
		<pubDate>Mon, 02 Nov 2009 22:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50074</guid>
		<description>Thanks a lot for the write up.  My one sticking point so far is on how to handle this when I have a class that holds a collection of these Enumeration types.  

For instance... 

public virtual IList MyStatusList
{
   get{ return ???? }
   set{ _statusList = ???? }
}

Any ideas on how to map these using Fluent NHibernate?</description>
		<content:encoded><![CDATA[<p>Thanks a lot for the write up.  My one sticking point so far is on how to handle this when I have a class that holds a collection of these Enumeration types.  </p>
<p>For instance&#8230; </p>
<p>public virtual IList MyStatusList<br />
{<br />
   get{ return ???? }<br />
   set{ _statusList = ???? }<br />
}</p>
<p>Any ideas on how to map these using Fluent NHibernate?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Cirerol</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50071</link>
		<dc:creator>Richard Cirerol</dc:creator>
		<pubDate>Mon, 02 Nov 2009 15:08:27 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50071</guid>
		<description>Ryan, I&#039;m sure I could post something. What are you not following? The implementation of the state pattern? Or the implementation of FNH? Or ...?</description>
		<content:encoded><![CDATA[<p>Ryan, I&#8217;m sure I could post something. What are you not following? The implementation of the state pattern? Or the implementation of FNH? Or &#8230;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Cromwell</title>
		<link>http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/comment-page-1/#comment-50070</link>
		<dc:creator>Ryan Cromwell</dc:creator>
		<pubDate>Mon, 02 Nov 2009 13:49:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2009/11/01/state-pattern-enumeration-class-and-fluent-nhibernate-oh-my/#comment-50070</guid>
		<description>Richard, Would you be willing to post a sample project showing what you&#039;ve done.  I&#039;m not sure I follow your final MyStatus implementation.</description>
		<content:encoded><![CDATA[<p>Richard, Would you be willing to post a sample project showing what you&#8217;ve done.  I&#8217;m not sure I follow your final MyStatus implementation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
