<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

<channel>
	<title>Ramblings of the Sleepy...</title>
	
	<link>http://tiredblogger.wordpress.com</link>
	<description>For an underpaid web architect and overplayed gamer... there is no such thing as sleep.</description>
	<lastBuildDate>Thu, 09 Jul 2009 17:58:13 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/e87df6e5b075c4485671acebd012921a?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Ramblings of the Sleepy...</title>
		<link>http://tiredblogger.wordpress.com</link>
	</image>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RamblingsOfTheSleepy" type="application/rss+xml" /><item>
		<title>Filtering an Enum by Attribute</title>
		<link>http://tiredblogger.wordpress.com/2009/07/09/filtering-an-enum-by-attribute/</link>
		<comments>http://tiredblogger.wordpress.com/2009/07/09/filtering-an-enum-by-attribute/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 16:59:08 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 2.0]]></category>
		<category><![CDATA[.net 3.0]]></category>
		<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/07/09/filtering-an-enum-by-attribute/</guid>
		<description><![CDATA[I had a curve ball thrown at me this morning&#8212;changing requirements.&#160; It happens and was easily solved by a couple of custom attributes and a helper method.
UPDATE: I&#8217;ve updated the code (and explaination) for FilterEnumWithAttributeOf below to tidy it up a bit.
In our current project,&#160;there is an enum of standard, static&#160;&#8220;periods&#8221; (times of days students [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=905&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I had a curve ball thrown at me this morning&mdash;changing requirements.&nbsp; It happens and was easily solved by a couple of custom attributes and a helper method.</p>
<p><font color="#ff0000"><strong>UPDATE: </strong>I&rsquo;ve updated the code (and explaination) for FilterEnumWithAttributeOf below to tidy it up a bit.</font></p>
<p>In our current project,&nbsp;there is an enum of standard, static&nbsp;&ldquo;periods&rdquo; (times of days students are in school).&nbsp; Easy enough.</p>
<blockquote>
<p>BeforeSchool = 0,<br />FirstPeriod = 1,<br />SecondPeriod&nbsp;= 2,<br />etc.</p>
</blockquote>
<p>But what happens if we want to &ldquo;query&rdquo; our list down a bit&hellip; say a certain group only wanted a subset of the &ldquo;periods&rdquo;.</p>
<p>I could create an entirely different Enum &mdash; Group1Period and Group2Period.</p>
<p>But then handling things in FluentNHibernate&rsquo;s automapping would get&nbsp;freaked out with the Period property.</p>
<p>So, what about a custom attribute?</p>
<ol>
<li>I can assign multiple custom attributes to the same Enum field so I can be in Group1 and Group2 at the same time.</li>
<li>I can keep the same Enum &ldquo;Period&rdquo; for my ORM layer.</li>
<li>Now how do I query it down&hellip;?</li>
</ol>
<p>Here&rsquo;s an abstracted example of how the enum looks right now:</p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;">
<p style="margin:0;"><span style="color:#8080c0;">public</span> <span style="color:#8080c0;">enum</span> <span style="color:#2b91af;">Period</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; [<span style="color:#c7c7f1;">Elementary</span>][<span style="color:#c7c7f1;">Secondary</span>]</p>
<p style="margin:0;">&nbsp; &nbsp; [<span style="color:#c7c7f1;">Description</span>(<span style="background:#820000;color:white;">"Before School"</span>)]</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#fef1a9;">BeforeSchool</span> = 0,</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; [<span style="color:#c7c7f1;">Elementary</span>]</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#fef1a9;">Homeroom</span> = 12,</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; [<span style="color:#c7c7f1;">Secondary</span>]</p>
<p style="margin:0;">&nbsp; &nbsp; [<span style="color:#c7c7f1;">Description</span>(<span style="background:#820000;color:white;">"1st"</span>)]</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#fef1a9;">First</span> = 1,</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Elementary and Secondary (our two groups, in this case) are &ldquo;logicless&rdquo; attributes (I&rsquo;m just looking at them as flags, not passing/storing information).</p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;">
<p style="margin:0;">[<span style="color:#c7c7f1;">AttributeUsage</span>(<span style="color:#2b91af;">AttributeTargets</span>.<span style="color:#fef1a9;">Field</span>)]</p>
<p style="margin:0;"><span style="color:#8080c0;">public</span> <span style="color:#8080c0;">class</span> <span style="color:#c7c7f1;">ElementaryAttribute</span> : <span style="color:#c7c7f1;">Attribute</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">}</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">[<span style="color:#c7c7f1;">AttributeUsage</span>(<span style="color:#2b91af;">AttributeTargets</span>.<span style="color:#fef1a9;">Field</span>)]</p>
<p style="margin:0;"><span style="color:#8080c0;">public</span> <span style="color:#8080c0;">class</span> <span style="color:#c7c7f1;">SecondaryAttribute</span> : <span style="color:#c7c7f1;">Attribute</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Now, to filter out those pesky periods based on the attributes.</p>
<p><strong><font color="#ff0000">Update: </font></strong></p>
<p><strong><font color="#ff0000">Old Code!</font></strong></p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;"><span style="color:#8080c0;"></p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;"><span style="color:#8080c0;"></p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;">
<p style="margin:0;"><span style="color:#8080c0;">public</span> <span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#fef1a9;">TEnum</span>&gt; <span style="color:#fef1a9;">FilterEnumWithAttributeOf</span>&lt;<span style="color:#fef1a9;">TEnum</span>, <span style="color:#fef1a9;">TAttribute</span>&gt;()</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#8080c0;">foreach</span> (<span style="color:#8080c0;">var</span> <span style="color:#fef1a9;">field</span> <span style="color:#8080c0;">in</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">typeof</span> (<span style="color:#fef1a9;">TEnum</span>).<span style="color:#fef1a9;">GetFields</span>(<span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">GetField</span> |</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">Public</span> |</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">Static</span>))</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">foreach</span> (<span style="color:#8080c0;">var</span> <span style="color:#fef1a9;">attribute</span> <span style="color:#8080c0;">in</span> </p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#fef1a9;">field</span>.<span style="color:#fef1a9;">GetCustomAttributes</span>(<span style="color:#8080c0;">typeof</span> (<span style="color:#fef1a9;">TAttribute</span>), <span style="color:#8080c0;">false</span>))</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">yield</span> <span style="color:#8080c0;">return</span> (<span style="color:#fef1a9;">TEnum</span>) <span style="color:#fef1a9;">field</span>.<span style="color:#fef1a9;">GetValue</span>(<span style="color:#8080c0;">null</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">}<font color="#e0e0e0"></font></p>
</div>
<p><!--EndFragment--></span></div>
<p><!--EndFragment--></span></div>
<p><!--EndFragment--></p>
<p><strong><font color="#ff0000">New Code!</font></strong></p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;">
<p style="margin:0;"><span style="color:#8080c0;">public</span> <span style="color:#8080c0;">static</span> <span style="color:#2b91af;">IEnumerable</span>&lt;<span style="color:#fef1a9;">TEnum</span>&gt; <span style="color:#fef1a9;">FilterEnumWithAttributeOf</span>&lt;<span style="color:#fef1a9;">TEnum</span>, <span style="color:#fef1a9;">TAttribute</span>&gt;()</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#8080c0;">where</span> <span style="color:#fef1a9;">TEnum</span> : <span style="color:#8080c0;">struct</span></p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#8080c0;">where</span> <span style="color:#fef1a9;">TAttribute</span> : <span style="color:#8080c0;">class</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#8080c0;">foreach</span> (<span style="color:#8080c0;">var</span> <span style="color:#fef1a9;">field</span> <span style="color:#8080c0;">in</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">typeof</span>(<span style="color:#fef1a9;">TEnum</span>).<span style="color:#fef1a9;">GetFields</span>(<span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">GetField</span> |</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">Public</span> |</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#2b91af;">BindingFlags</span>.<span style="color:#fef1a9;">Static</span>))</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">if</span> (<span style="color:#fef1a9;">field</span>.<span style="color:#fef1a9;">GetCustomAttributes</span>(<span style="color:#8080c0;">typeof</span>(<span style="color:#fef1a9;">TAttribute</span>), <span style="color:#8080c0;">false</span>).<span style="color:#fef1a9;">Length</span> &gt; 0)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#8080c0;">yield</span> <span style="color:#8080c0;">return</span> (<span style="color:#fef1a9;">TEnum</span>)<span style="color:#fef1a9;">field</span>.<span style="color:#fef1a9;">GetValue</span>(<span style="color:#8080c0;">null</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">} </p>
</div>
<p><strong><font color="#ff0000">Why new code?</font></strong></p>
<p><font color="#ff0000">Well, after looking over the code, I don&rsquo;t need to iterate through each attribute, simply see if the field contains it (Length &gt; 0).&nbsp; If it does, then return it.&nbsp; That cuts a loop out of our code and performs the same function.&nbsp; I also added two generic constraints.&nbsp; You can&rsquo;t constrain by Enum, but struct works well.</font></p>
<p>I&rsquo;m passing in two generics in this case&mdash;TEnum, which is the type of the of the Enum and TAttribute.. the type of the attribute.&nbsp; Yeah, I realize that my creativity of naming is pretty low.&nbsp; Work with me here, alright? <img src='http://s.wordpress.com/wp-includes/images/smilies/face-wink.png' alt=';)' class='wp-smiley' /> </p>
<p>Past that, the loops are pretty easy.</p>
<ol>
<li>Loop through each field of the enumeration.&nbsp; Return the field (GetField) and be sure to check Public and Static fields.</li>
<li><font color="#ff0000"><strike>Loop through each custom attribute on each field (returned by GetField) and only return the fields that match the type of our attribute.&nbsp; I pass along the false parameter (do not inherit) because I&rsquo;m not interested in inherited attributes.&nbsp;You could leave this as true. YMMV</strike></font>.</li>
<li>If the field&rsquo;s attribute&rsquo;s contains our type, yield out the actual Enum value (a string of the field isn&rsquo;t as useful).</li>
</ol>
<p>Now, for using it&hellip;</p>
<div style="font-family:Monaco, Consolas;background:#181818;color:#e0e0e0;font-size:8pt;">
<p style="margin:0;"><span style="color:#8080c0;">var</span> <span style="color:#fef1a9;">enums</span> = <span style="color:#fef1a9;">FilterEnumWithAttributeOf</span>&lt;<span style="color:#2b91af;">Period</span>, <span style="color:#c7c7f1;">ElementaryAttribute</span>&gt;();</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;"><span style="color:#8080c0;">foreach</span> (<span style="color:#8080c0;">var</span> <span style="color:#fef1a9;">period</span> <span style="color:#8080c0;">in</span> <span style="color:#fef1a9;">enums</span>)</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#c7c7f1;">Console</span>.<span style="color:#fef1a9;">WriteLine</span>(<span style="background:#820000;color:white;">&#8220;{0}, {1}&#8221;</span>.<span style="color:#fef1a9;">AsFormatFor</span>(<span style="color:#fef1a9;">period</span>, (<span style="color:#8080c0;">int</span>)<span style="color:#fef1a9;">period</span>));</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Easy enough.&nbsp; ElementaryAttribute returns:</p>
<blockquote>
<p>BeforeSchool,&nbsp;0<br />Homeroom,&nbsp;12<br />AfterSchool,&nbsp;10<br />etc..</p>
</blockquote>
<p dir="ltr">Running the same code, but asking for SecondaryAttribute returns:</p>
<blockquote>
<p dir="ltr">BeforeSchool,&nbsp;0<br />First,&nbsp;1<br />Second,&nbsp;2<br />etc..</p>
</blockquote>
<p dir="ltr">Sweet.</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/enum">enum</a>, <a rel="tag" href="http://technorati.com/tag/c#">c#</a>, <a rel="tag" href="http://technorati.com/tag/generics">generics</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/905/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=905&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/07/09/filtering-an-enum-by-attribute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>AutoMappings in NHibernate – A Quick Runthrough</title>
		<link>http://tiredblogger.wordpress.com/2009/06/26/automappings-in-nhibernate-a-quick-runthrough/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/26/automappings-in-nhibernate-a-quick-runthrough/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 19:58:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 2.0]]></category>
		<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[Fluent NHibernate]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/26/automappings-in-nhibernate-a-quick-runthrough/</guid>
		<description><![CDATA[For most of my projects, at least since I&#8217;ve moved to NHibernate/Fluent NHibernate, I&#8217;ve been trapped using the existing data structures of prior iterations.&#160; Funky naming conventions (many due to cross-cultural, international column naming), missing data relationships, and general craziness.
Having used Fluent Mappings (creating a class that implements ClassMap&#60;objectType&#62;)&#160;in the past, they were a huge [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=897&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>For most of my projects, at least since I&rsquo;ve moved to NHibernate/Fluent NHibernate, I&rsquo;ve been trapped using the existing data structures of prior iterations.&nbsp; Funky naming conventions (many due to cross-cultural, international column naming), missing data relationships, and general craziness.</p>
<p>Having used Fluent Mappings (creating a class that implements ClassMap&lt;objectType&gt;)&nbsp;in the past, they were a huge jump up from writing painful data objects, connecting them together, and recreating the wheel with &ldquo;SELECT {column} from {table}&rdquo; code.&nbsp; Create a map, use the fluent methods to match column to property, and away you go.</p>
<p>In a recent project, I&rsquo;ve had the opportunity to build a new system from the ground up.&nbsp; With this, I decided to dive head first into using the AutoMappings functionality of Fluent NHibernate.&nbsp; </p>
<p><em>This post is somewhat a rambling self-discussion of my explorations with AutoMappings.</em></p>
<p><strong><u>What are AutoMappings?</u></strong></p>
<p>The FluentNHibernate wiki provides a simple <a href="http://is.gd/1eJeG" target="_blank">definition</a>:</p>
<blockquote>
<p>[&hellip;] which is a mechanism for automatically mapping all your entities based on a set of conventions.</p>
</blockquote>
<p dir="ltr">Rather than hand-mapping each column to a property, we create conventions (rules) to map those.. automatically.&nbsp; Hey look, auto&hellip;mappings.&nbsp; <img src='http://s.wordpress.com/wp-includes/images/smilies/face-wink.png' alt=';)' class='wp-smiley' /> </p>
<p dir="ltr"><strong><u>How?</u></strong></p>
<p dir="ltr">Using the same fluent language, configuring AutoMapping is an exercise in implementing conventions for the logical naming and handling of data.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#2bdad5;">Fluently</span></p>
<p style="margin:0;">&nbsp; &nbsp; .Configure()</p>
<p style="margin:0;">&nbsp; &nbsp; .Database(<span style="color:#2bdad5;">MsSqlConfiguration</span>.MsSql2005</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .ConnectionString(cs =&gt; cs</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Server(<span style="background:#6f0205;color:white;">&#8220;server&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Database(<span style="background:#6f0205;color:white;">&#8220;db&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Username(<span style="background:#6f0205;color:white;">&#8220;user&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Password(<span style="background:#6f0205;color:white;">&#8220;password&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .UseReflectionOptimizer()</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .UseOuterJoin()</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .AdoNetBatchSize(<span style="color:aqua;font-weight:bold;">10</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .DefaultSchema(<span style="background:#6f0205;color:white;">&#8220;dbo&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .ShowSql()</p>
<p style="margin:0;">&nbsp; &nbsp; )</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; .ExposeConfiguration(raw =&gt;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#9ea928;">// Testing/NHibernate Profiler stuffs.</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; raw.SetProperty(<span style="background:#6f0205;color:white;">&#8220;generate_statistics&#8221;</span>, <span style="background:#6f0205;color:white;">&#8220;true&#8221;</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; RebuildSchema(raw);</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; })</p>
<p style="margin:0;">&nbsp; &nbsp; .Mappings(m =&gt;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m.AutoMappings.Add(<span style="color:#2bdad5;">AutoPersistenceModel</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; .MapEntitiesFromAssemblyOf&lt;<span style="color:#2bdad5;">Walkthrough</span>&gt;()</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; .ConventionDiscovery.Setup(c =&gt;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.Add&lt;<span style="color:#2bdad5;">EnumMappingConvention</span>&gt;();</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.Add&lt;<span style="color:#2bdad5;">ReferencesConvention</span>&gt;();</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.Add&lt;<span style="color:#2bdad5;">HasManyConvention</span>&gt;();</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.Add&lt;<span style="color:#2bdad5;">ClassMappingConvention</span>&gt;();</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; .WithSetup(c =&gt; c.IsBaseType = type =&gt; type == <span style="color:#ff7c05;">typeof</span> (<span style="color:#2bdad5;">Entity</span>)))</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .ExportTo(<span style="background:#6a0609;color:white;">@&#8221;.\&#8221;</span>)</p>
<p style="margin:0;">&nbsp; &nbsp; );</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">As you can see above, the only difference from a&nbsp;fluent mappings configuration is in the actual Mappings area.&nbsp; Good deal!&nbsp; That helps ensure my existing work using fluent mappings could translate without too much headache.</p>
<p dir="ltr">I&rsquo;ve specified four conventions.&nbsp; Each of these conventions have interfaces that provide the necessary methods to ensure your rules are appied to the correct objects.</p>
<p dir="ltr"><strong>EnumMappingConvention</strong></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">internal</span> <span style="color:#ff7c05;">class</span> <span style="color:#2bdad5;">EnumMappingConvention</span> : <span style="color:#2b91af;">IUserTypeConvention</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">bool</span> Accept(<span style="color:#2b91af;">IProperty</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> target.PropertyType.IsEnum;</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> Apply(<span style="color:#2b91af;">IProperty</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.CustomTypeIs(target.PropertyType);</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">bool</span> Accept(<span style="color:#2bdad5;">Type</span> type)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> type.IsEnum;</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">The great thing about these methods is they&rsquo;re fluent enough to translate to English.</p>
<p dir="ltr">Accept&hellip; targets where the property type is an enumeration.</p>
<p dir="ltr">Apply&hellip; to the target that the &ldquo;Custom Type Is&rdquo; the property type of the target.<br />&nbsp; <strong>NOTE: </strong>This translates from a ClassMap into: Map(x =&gt; x.MyEnumFlag).CustomTypeIs(typeof(MyEnum));</p>
<p dir="ltr">Accept&hellip; a type that is an enumeration.</p>
<p dir="ltr"><strong>ReferenceConvention</strong></p>
<p dir="ltr">The Reference convention handles those reference relationships between our classes (and the foreign keys).</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">internal</span> <span style="color:#ff7c05;">class</span> <span style="color:#2bdad5;">ReferencesConvention</span> : <span style="color:#2b91af;">IReferenceConvention</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">bool</span> Accept(<span style="color:#2b91af;">IManyToOnePart</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> <span style="color:#ff7c05;">string</span>.IsNullOrEmpty(target.GetColumnName());</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> Apply(<span style="color:#2b91af;">IManyToOnePart</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.ColumnName(target.Property.Name + <span style="background:#6f0205;color:white;">&#8220;Id&#8221;</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">The most important part here is enforcing how your foreign keys are going to be named.&nbsp; I prefer the simple {Object}Id format.</p>
<p dir="ltr">Car.Battery on the object side and [Car].[BatteryId] on the database side.</p>
<p dir="ltr"><strong>HasManyConvention</strong></p>
<p dir="ltr">The HasManys are our lists, bags, and collections of objects.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">internal</span> <span style="color:#ff7c05;">class</span> <span style="color:#2bdad5;">HasManyConvention</span> : <span style="color:#2b91af;">IHasManyConvention</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">bool</span> Accept(<span style="color:#2b91af;">IOneToManyPart</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> target.KeyColumnNames.List().Count == <span style="color:aqua;font-weight:bold;">0</span>;</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> Apply(<span style="color:#2b91af;">IOneToManyPart</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.KeyColumnNames.Add(target.EntityType.Name + <span style="background:#6f0205;color:white;">&#8220;Id&#8221;</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.Cascade.AllDeleteOrphan();</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.Inverse();</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">We want to make sure that we haven&rsquo;t added any other key columns (the Count == 0), and then apply both the naming convention as well as a few properties.</p>
<p dir="ltr">Cascade.AllDeleteOrphan() and Inverse() allows our parent objects (Car) to add new child objects (Car.Battery (Battery), Car.Accessories (IList&lt;Accessory&gt;)) without separating them out.</p>
<p dir="ltr"><strong>ClassMappingConvention</strong></p>
<p dir="ltr">Finally, the important Class mapping.&nbsp; This convention ensures that our tables are named property with pluralization.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">class</span> <span style="color:#2bdad5;">ClassMappingConvention</span> : <span style="color:#2b91af;">IClassConvention</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">bool</span> Accept(<span style="color:#2b91af;">IClassMap</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> <span style="color:#ff7c05;">true</span>; <span style="color:#9ea928;">// everything</span></p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> Apply(<span style="color:#2b91af;">IClassMap</span> target)</p>
<p style="margin:0;">&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; target.WithTable(PluralOf(target.EntityType.Name));</p>
<p style="margin:0;">&nbsp; &nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">I&rsquo;m using a pluralization method from one of my base libraries that I borrowed from Hudson Akridge.&nbsp; This helper method works really well and I don&rsquo;t need to add additional references and libraries into my application just to handle the table names.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">static</span> <span style="color:#ff7c05;">string</span> PluralOf(<span style="color:#ff7c05;">string</span> text)</p>
<p style="margin:0;">&nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">var</span> pluralString = text<font color="#ffffff">;</font></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">var</span> lastCharacter = pluralString.Substring(pluralString.Length &#8211; <span style="color:aqua;font-weight:bold;">1</span>).ToLower();</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#9ea928;">// y&#8217;s become ies (such as Category to Categories)</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">if</span> (<span style="color:#ff7c05;">string</span>.Equals(lastCharacter, <span style="background:#6f0205;color:white;">&#8220;y&#8221;</span>, <span style="color:#2b91af;">StringComparison</span>.InvariantCultureIgnoreCase))</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pluralString = pluralString.Remove(pluralString.Length &#8211; <span style="color:aqua;font-weight:bold;">1</span>);</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pluralString += <span style="background:#6f0205;color:white;">&#8220;ie&#8221;</span>;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#9ea928;">// ch&#8217;s become ches (such as Pirch to Pirches)</span></p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">if</span> (<span style="color:#ff7c05;">string</span>.Equals(pluralString.Substring(pluralString.Length &#8211; <span style="color:aqua;font-weight:bold;">2</span>), <span style="background:#6f0205;color:white;">&#8220;ch&#8221;</span>,</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#2b91af;">StringComparison</span>.InvariantCultureIgnoreCase))</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pluralString += <span style="background:#6f0205;color:white;">&#8220;e&#8221;</span>;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">switch</span> (lastCharacter)</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">case</span> <span style="background:#6f0205;color:white;">&#8220;s&#8221;</span>:</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> pluralString + <span style="background:#6f0205;color:white;">&#8220;es&#8221;</span>;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">default</span>:</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#ff7c05;">return</span> pluralString + <span style="background:#6f0205;color:white;">&#8220;s&#8221;</span>;</p>
<p style="margin:0;">&nbsp; &nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp; }</p>
</div>
<p><!--EndFragment--></p>
<p dir="ltr">Save and build.&nbsp; The ExportSchema method will generate the SQL and/or regen the database based on the specifications you&rsquo;ve provided to it. and you&rsquo;re ready to hit the ground running!</p>
<p dir="ltr">&nbsp;</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/fluent+nhibernate">fluent+nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/automapping">automapping</a>, <a rel="tag" href="http://technorati.com/tag/nhibernate">nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/sql+server+2005">sql+server+2005</a>, <a rel="tag" href="http://technorati.com/tag/.net+3.5">.net+3.5</a>, <a rel="tag" href="http://technorati.com/tag/c#">c#</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/897/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=897&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/26/automappings-in-nhibernate-a-quick-runthrough/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Rendering the Web Equally on Mobile Devices</title>
		<link>http://tiredblogger.wordpress.com/2009/06/26/rendering-the-web-equally-on-mobile-devices/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/26/rendering-the-web-equally-on-mobile-devices/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:57:00 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 2.0]]></category>
		<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/26/rendering-the-web-equally-on-mobile-devices/</guid>
		<description><![CDATA[I&#8217;ve been digging through the Interwebs for a while now and, I thought, had worked out all of the &#8220;kinks&#8221; of rendering on a mobile device&#8212;specifically iPhones.
The special &#8216;viewport&#8217; meta tag means the world to iDevices.

meta name=&#8220;viewport&#8221; content=&#8220;width = device-width&#8221; /&#62;


I&#8217;m faced with a new challenge&#8212;the Palm Pre&#8217;s built-in web browser.&#160; My shiny new phone [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=895&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&rsquo;ve been digging through the Interwebs for a while now and, I thought, had worked out all of the &ldquo;kinks&rdquo; of rendering on a mobile device&mdash;specifically iPhones.</p>
<p>The <a href="http://is.gd/1etNw" target="_blank">special &lsquo;viewport&rsquo; meta tag</a> means the world to iDevices.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">meta</span> name=<span style="color:lime;">&#8220;viewport&#8221;</span> content=<span style="color:lime;">&#8220;width = device-width&#8221;</span> <span style="color:yellow;">/&gt;</span></p>
</div>
<p><!--EndFragment--></p>
<p>I&rsquo;m faced with a new challenge&mdash;the Palm Pre&rsquo;s built-in web browser.&nbsp; My shiny new phone is great, but it isn&rsquo;t without glitches.</p>
<p>The first glitch I&rsquo;ve found appears to be a DNS issue&mdash; <a href="http://myserver/web">http://myserver/web</a>&nbsp;won&rsquo;t resolve; however, <a href="http://123.45.67.89/web">http://123.45.67.89/web</a> will.&nbsp; It seems to be touchy.&nbsp; Most of our webs work just fine, others don&rsquo;t.&nbsp; I haven&rsquo;t narrowed it down to a single server or architecture as it seems to be a bit of everything.&nbsp; Wonky.</p>
<p>The next glitch is more important&mdash;the rendering.&nbsp; One of our tools is a simple form-based tool that looks great on the iPhone; however, renders partial screen and &ldquo;garbles&rdquo; when you move around the screen.</p>
<p><strong>Palm Pre:</strong></p>
<p><img border="2" hspace="5" alt="Garbled image" vspace="5" src="http://is.gd/1etgs" /></p>
<p><strong>iTouch/iPhone:</strong></p>
<p><img border="2" hspace="5" alt="" vspace="5" src="http://is.gd/1eux1" /></p>
<p>I&rsquo;ve also found that anything in an ASP.NET Update Panel (like those Select buttons) are unusable.&nbsp; Other webs I&rsquo;ve used (Bank of America, etc) use AJAX just fine, so I don&rsquo;t think it&rsquo;s that&mdash;probably a coding issue I need to dig into and resolve.</p>
<p><strong>UPDATE: </strong>Explicitly adding &ldquo;LoadScriptsBeforeUI=&rsquo;true&rsquo;&rdquo; to the ASP.NET ScriptManager seems to help with this.. a little.</p>
<p>Anyone else worked specifically with the Pre devices and rendering?&nbsp; I&rsquo;d appreciate any meta tags or layout ideas that worked. <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> &nbsp; The Pre isn&rsquo;t a common device in our organization&mdash;yet.</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/Palm+Pre">Palm+Pre</a>, <a rel="tag" href="http://technorati.com/tag/iPhone">iPhone</a>, <a rel="tag" href="http://technorati.com/tag/asp.net">asp.net</a>, <a rel="tag" href="http://technorati.com/tag/ajax">ajax</a>, <a rel="tag" href="http://technorati.com/tag/mobile+web">mobile+web</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/895/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=895&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/26/rendering-the-web-equally-on-mobile-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>

		<media:content url="http://is.gd/1etgs" medium="image">
			<media:title type="html">Garbled image</media:title>
		</media:content>

		<media:content url="http://is.gd/1eux1" medium="image" />
	</item>
		<item>
		<title>Benchmarks : Comparing LINQ to NHibernate Transforms/Grouping</title>
		<link>http://tiredblogger.wordpress.com/2009/06/12/benchmarks-comparing-linq-to-nhibernate-transformsgrouping/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/12/benchmarks-comparing-linq-to-nhibernate-transformsgrouping/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 14:07:37 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[Fluent NHibernate]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/12/benchmarks-comparing-linq-to-nhibernate-transformsgrouping/</guid>
		<description><![CDATA[Yesterday, I wrote about setting up NHibernate to query up, group, count, and transform results and return them into a control.&#160; Why did I go to such effort?&#160; Well, the original LINQ query I had that refined the results didn&#8217;t perform up to par.&#160; As some may note, premature optimization is never a good practice [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=891&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Yesterday, I <a href="http://is.gd/ZMhR" target="_blank">wrote</a> about setting up NHibernate to query up, group, count, and transform results and return them into a control.&nbsp; Why did I go to such effort?&nbsp; Well, the original LINQ query I had that refined the results didn&rsquo;t perform up to par.&nbsp; As some may note, premature optimization is never a good practice so I needed some stats to back up the claims.</p>
<p>Overnight, I wrote up a quick test to query up both ways and benchmark the results.&nbsp; Here&rsquo;s what I found.</p>
<p><strong>The &ldquo;test&rdquo;:</strong></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> TEMP_quick_compare_of_linq_to_nhibernate()</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> schoolId = <span style="color:aqua;font-weight:bold;">120</span>;</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> benchmark = <span style="color:#ff7c05;">new</span> <span style="color:#2bdad5;">Benchmark</span>();</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">using</span> (<span style="color:#ff7c05;">var</span> repository = <span style="color:#ff7c05;">new</span> <span style="color:#2bdad5;">IncidentRepository</span>())</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; benchmark.Start();</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> resultsFromLinq = </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; repository.GetCountByIncidentCodeWithLinq(schoolId);</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">foreach</span> (<span style="color:#ff7c05;">var</span> item <span style="color:#ff7c05;">in</span> resultsFromLinq) </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#2bdad5;">Console</span>.WriteLine(item);</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; benchmark.Stop();</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#2bdad5;">Console</span>.WriteLine(<span style="background:#6f0205;color:white;">&#8220;Linq: {0}&#8221;</span>.AsFormatFor(benchmark.ElapsedTime));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; benchmark.Start();</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> resultsFromNhibernate = </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; repository.GetCountByIncidentCode(schoolId);</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">foreach</span> (<span style="color:#ff7c05;">var</span> item <span style="color:#ff7c05;">in</span> resultsFromNhibernate)</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#2bdad5;">Console</span>.WriteLine(item);</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; benchmark.Stop();</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#2bdad5;">Console</span>.WriteLine(<span style="background:#6f0205;color:white;">&#8220;NHibernate: {0}&#8221;</span>.AsFormatFor(benchmark.ElapsedTime));</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Setting up the benchmark (and the NHibernate Init) are outside of the benchmark&mdash;they&rsquo;re necessary overhead.&nbsp; I&rsquo;m&nbsp;also iterating through each of the results as part of the benchmark to ensure that everything is evaluated. Past that, pretty basic.&nbsp; On the database side, I&rsquo;ve disabled statement caching to not sway the results as much.</p>
<p>With 24 records (the test data in the system), the results were pretty clear.&nbsp;The average of running the benchmark 100 times resulted in&hellip;</p>
<blockquote>
<p>Linq:&nbsp;00:00:00.7050000<br />NHibernate:&nbsp;00:00:00.0190000</p>
</blockquote>
<p>With 24 records, NHibernate was about 37x faster.&nbsp; </p>
<p>That&rsquo;s nice, but what happens in a few&nbsp;weeks when there are a few&nbsp;thousand records?&nbsp; I populated a few hundred of each incident type into the system, giving me almost 4000 records (the anticipated monthly load of the system by the customer).&nbsp; How&rsquo;d that change our averages?</p>
<blockquote>
<p>Linq:&nbsp;00:00:00.8869746<br />NHibernate:&nbsp;00:00:00.1381518</p>
</blockquote>
<p>Now we&rsquo;re only 6x faster with NHibernate vs. LINQ.&nbsp; The duration from 24 to 4000 records for LINQ&nbsp; jumped ~.18 seconds for a 25% gain&nbsp;where as NHibernate jumped ~.11 seconds for a 626% gain.</p>
<p>So, with that, my original gut feeling and assumptions were <strong><u>wrong</u></strong>.&nbsp; More and more records don&rsquo;t really slow down the LINQ filtering.. at least not by much.&nbsp; The performance gain is still appparent between the two methods (.88 sec vs. .13 sec); however, how much of that time is eaten up by rendering, server latency, etc and not by the actual processing?</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/nhibernate">nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/linq">linq</a>, <a rel="tag" href="http://technorati.com/tag/performance">performance</a>, <a rel="tag" href="http://technorati.com/tag/c#">c#</a>, <a rel="tag" href="http://technorati.com/tag/asp.net">asp.net</a>, <a rel="tag" href="http://technorati.com/tag/optimization">optimization</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/891/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/891/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/891/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/891/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/891/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/891/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/891/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/891/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/891/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/891/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=891&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/12/benchmarks-comparing-linq-to-nhibernate-transformsgrouping/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Grouping and Transforming Using NHibernate</title>
		<link>http://tiredblogger.wordpress.com/2009/06/11/grouping-and-transforming-using-nhibernate/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/11/grouping-and-transforming-using-nhibernate/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 20:37:15 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/11/grouping-and-transforming-using-nhibernate/</guid>
		<description><![CDATA[Okay, I&#8217;ve got to be doing this wrong.
Call it premature optimization, but I forsee an old LINQ method being a performance bottleneck when we hit a few hundred thousands records&#8212;especially for the ASP.NET charting control to render in any useful time period.
So, what do I do?&#160; I figure pushing that computation back down to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=885&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Okay, I&rsquo;ve <strong><u>got</u></strong> to be doing this wrong.</p>
<p>Call it premature optimization, but I forsee an old LINQ method being a performance bottleneck when we hit a few hundred thousands records&mdash;especially for the ASP.NET charting control to render in any useful time period.</p>
<p>So, what do I do?&nbsp; I figure pushing that computation back down to the database would be a good first step.</p>
<p>Unfortunately, grouping, sorting, and such are a serious pain in the ass.&nbsp; Unless, as I said, I&rsquo;m doing it wrong.</p>
<p><strong><u>Original Code &ndash; Grouping and Counting ala LINQ</u></strong></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">private</span> <span style="color:#2b91af;">IList</span> GetIncidentsGroupedByIncidentCode()</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">using</span> (<span style="color:#ff7c05;">var</span> repository = <span style="color:#ff7c05;">new</span> <span style="color:#2bdad5;">IncidentRepository</span>())</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> allIncidents = </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; repository.GetAllBySchoolId(<span style="color:#2bdad5;">SessionManager</span>.CurrentSchoolId);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> incidentsByCode = <span style="color:#ff7c05;">from</span> i <span style="color:#ff7c05;">in</span> allIncidents</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#ff7c05;">group</span> i <span style="color:#ff7c05;">by</span> i.IncidentCodeId</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#ff7c05;">into</span> grouping</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">orderby</span> grouping.Count()</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">select</span> <span style="color:#ff7c05;">new</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IncidentCodeId = grouping.Key,</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Count = grouping.Count(),</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Description = </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetIncidentCodeDescription(grouping.Key)</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; };</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">return</span> incidentsByCode.ToList();</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Grab all incidents (using&nbsp;NHibernate repository)&nbsp;and use LINQ to transform them into a new handy anonymous type that consisted of the IncidentCodeId, a Count (by IncidentCodeId), and the Description which uses the IncidentCodeId to grab the description (the incident code description is coming from an entirely different system/database, hence the method to go fetch it).</p>
<p>I can simply return an IList rather than specifying the type (since it&rsquo;s anonymous) and get away with loading up my Chart Control&mdash;not a problem.</p>
<p><strong><u>Newish Code &ndash; Grouping and Counting ala NHibernate</u></strong></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#2b91af;">IList</span> GetCountByIncidentCode(<span style="color:#ff7c05;">int</span> schoolId)</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">using</span> (<span style="color:#ff7c05;">var</span> tx = Session.BeginTransaction())</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> criteria = Session.CreateCriteria(<span style="color:#ff7c05;">typeof</span> (<span style="color:#2bdad5;">Incident</span>));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Only get those matching the requested SchoolId</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.Add(<span style="color:#2bdad5;">RestrictionsHelper</span>&lt;<span style="color:#2bdad5;">Incident</span>&gt;.Eq(x =&gt; x.SchoolId, schoolId));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Setup our projections.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// IncidentCodeId is what we&#8217;re using as an Identifier.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Id is what we&#8217;re counting, so the results of the &#8220;GroupedResult&#8221; go into Result</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// and we&#8217;re grouping by IncidentCodeId</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.SetProjection(<span style="color:#2bdad5;">Projections</span>.ProjectionList()</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; .Add(<span style="color:#2bdad5;">Projections</span>.Property(<span style="background:#6f0205;color:white;">&#8220;IncidentCodeId&#8221;</span>), <span style="background:#6f0205;color:white;">&#8220;Identifier&#8221;</span>)</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; .Add(<span style="color:#2bdad5;">Projections</span>.Count(<span style="background:#6f0205;color:white;">&#8220;Id&#8221;</span>), <span style="background:#6f0205;color:white;">&#8220;Result&#8221;</span>)</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; .Add(<span style="color:#2bdad5;">Projections</span>.GroupProperty(<span style="background:#6f0205;color:white;">&#8220;IncidentCodeId&#8221;</span>)));</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Order THAT mess by Result</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.AddOrder(<span style="color:#2bdad5;">Order</span>.Asc(<span style="background:#6f0205;color:white;">&#8220;Result&#8221;</span>));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Now, since we can&#8217;t use anonymous objects (??), we have to use a funky Java</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// method to transform it into a typed result.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.SetResultTransformer(<span style="color:#2bdad5;">Transformers</span>.AliasToBean(<span style="color:#ff7c05;">typeof</span> (<span style="color:#2bdad5;">GroupedResult</span>)));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Convert this all to a list.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">var</span> result = criteria.List&lt;<span style="color:#2bdad5;">GroupedResult</span>&gt;() <span style="color:#ff7c05;">as</span> <span style="color:#2bdad5;">List</span>&lt;<span style="color:#2bdad5;">GroupedResult</span>&gt;;</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Commit&#8230; or get committed.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; tx.Commit();</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">if</span> (result != <span style="color:#ff7c05;">null</span>)</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#9ea928;">// We can&#8217;t do this inline (??), so go back into the list and iterate through&#8230; grabbing</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#9ea928;">// descriptions.</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; result.ForEach(x =&gt;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color:#ff7c05;">var</span> description =</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetIncidentCodeDescription(x.Identifier.ConvertTo&lt;<span style="color:#ff7c05;">int</span>&gt;());</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; x.Description = description;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; });</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// Holy crap, we&#8217;re done!</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#ff7c05;">return</span> result;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>What&hellip; the&hellip; heck?</p>
<p>Amazingly enough, that works (changing the chart&rsquo;s column names, of course).&nbsp; And it&rsquo;s relatively quick&hellip; But woah, what a mess.&nbsp; </p>
<p>It also adds annoying little &lsquo;result&rsquo; objects into the mix.&nbsp; </p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">class</span> <span style="color:#2bdad5;">GroupedResult</span></p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">int</span> Identifier { <span style="color:#ff7c05;">get</span>; <span style="color:#ff7c05;">set</span>; }</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">string</span> Description { <span style="color:#ff7c05;">get</span>; <span style="color:#ff7c05;">set</span>; }</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">int</span> Result { <span style="color:#ff7c05;">get</span>; <span style="color:#ff7c05;">set</span>; }</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>Strongly typed is stellar and I&rsquo;m pretty sure I could have some generic objects. [Identifier/Description/Result] could work for counts, averages, most anything that is grouped up, but that just twitches me out a bit to have random classes sitting around for data transformations.</p>
<p>So, good readers&mdash;how is this REALLY supposed to work?&nbsp; All that to generate the guts of:</p>
<p>SELECT COUNT(IncidentCodeId) as Result, IncidentCodeId<br />FROM Incidents<br />WHERE SchoolId = :schoolId<br />GROUP BY IncidentCodeId<br />ORDER BY Result</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/fluent+nhibernate">fluent+nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/nhibernate">nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/sql">sql</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/885/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/885/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/885/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/885/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/885/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/885/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/885/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/885/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/885/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/885/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=885&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/11/grouping-and-transforming-using-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Performing SELECT.. WHERE IN using a Repository</title>
		<link>http://tiredblogger.wordpress.com/2009/06/08/performing-select-where-in-using-a-repository/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/08/performing-select-where-in-using-a-repository/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 16:54:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/08/performing-select-where-in-using-a-repository/</guid>
		<description><![CDATA[As I&#8217;ve discussed in the past, a few of my repository pattern practices are borrowed and built on the nice S#arp Architecture project.&#160; Here&#8217;s another situation where I needed a bit more functionality.
Disclaimer:&#160; If there&#8217;s a better way to do this&#8212;I&#8217;m all ears and emails.  
By default, the FindAll method builds up the NHibernate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=879&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>As I&rsquo;ve discussed in the past, a few of my repository pattern practices are borrowed and built on the nice <a href="http://code.google.com/p/sharp-architecture/" target="_blank">S#arp Architecture</a> project.&nbsp; Here&rsquo;s another situation where I needed a bit more functionality.</p>
<p>Disclaimer:&nbsp; If there&rsquo;s a better way to do this&mdash;I&rsquo;m all ears and emails. <img src='http://s.wordpress.com/wp-includes/images/smilies/face-smile.png' alt=':)' class='wp-smiley' /> </p>
<p>By default, the FindAll method builds up the NHibernate criteria by iterating through a key/value pair.&nbsp; Easy enough.</p>
<blockquote>
<p>&lsquo;Id, 12345&rsquo; generates &lsquo;WHERE Id = 12345&rsquo;.</p>
</blockquote>
<p>But what happens when I want to do something with an array?</p>
<blockquote>
<p>&lsquo;Id, int[] {12345, 67890}&rsquo; <strong><u>should</u></strong> generate &lsquo;WHERE Id IN (12345, 67890)&rsquo;</p>
</blockquote>
<p>Thankfully, the Restrictions class has an In method, but how can I add that flexibility to the FindAll method?</p>
<p>Here&rsquo;s what the FindAll method looks like to start off:</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> T Find(<span style="color:#2b91af;">IDictionary</span>&lt;<span style="color:#ff7c05;">string</span>, <span style="color:#ff7c05;">object</span>&gt; propertyValuePairs)</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2bdad5;">Check</span>.Require(propertyValuePairs != <span style="color:#ff7c05;">null</span>,</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="background:#6f0205;color:white;">&#8220;propertyValuePairs was null or empty&#8221;</span>);</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2bdad5;">Check</span>.Require(propertyValuePairs.Count &gt; <span style="color:aqua;font-weight:bold;">0</span>,</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="background:#6f0205;color:white;">&#8220;propertyValuePairs must contain at least one pair&#8221;</span>);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> criteria = Session.CreateCriteria(<span style="color:#ff7c05;">typeof</span> (T));</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; propertyValuePairs</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; .ForEach(x =&gt;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.Add(<span style="color:#2bdad5;">Restrictions</span>.Eq(x.Key, x.Value)));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">return</span> criteria.List&lt;T&gt;() <span style="color:#ff7c05;">as</span> <span style="color:#2bdad5;">List</span>&lt;T&gt;;</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></p>
<p>That&rsquo;s nice.&nbsp; Iterate through each, but assuming an Eq (Equals) relationship between the key and the value.</p>
<p>After a bit of dinking, checking to see if the object is a typeof(<a href="http://is.gd/TmEo" target="_blank">ICollection</a>) seems to be the most reliable considering Restrictions.In(key,value) accepts Collections for the value parameter.&nbsp;</p>
<p>This allows you to pass arrays, lists, and dictionaries.</p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;"><span style="color:#ff7c05;"></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#2bdad5;">List</span>&lt;T&gt; FindAll(<span style="color:#2b91af;">IDictionary</span>&lt;<span style="color:#ff7c05;">string</span>, <span style="color:#ff7c05;">object</span>&gt; propertyValuePairs)</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2bdad5;">Check</span>.Require(propertyValuePairs != <span style="color:#ff7c05;">null</span>,</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="background:#6f0205;color:white;">&#8220;propertyValuePairs was null or empty&#8221;</span>);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2bdad5;">Check</span>.Require(propertyValuePairs.Count &gt; <span style="color:aqua;font-weight:bold;">0</span>,</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="background:#6f0205;color:white;">&#8220;propertyValuePairs must contain at least one pair&#8221;</span>);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">ICriteria</span> criteria = Session.CreateCriteria(<span style="color:#ff7c05;">typeof</span> (T));</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; propertyValuePairs</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; .ForEach(x =&gt;</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">if</span> (x.Value.IsA&lt;<span style="color:#2b91af;">ICollection</span>&gt;())</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// add WHERE key IN (value)</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.Add(<span style="color:#2bdad5;">Restrictions</span>.In(x.Key, (<span style="color:#2b91af;">ICollection</span>) x.Value));</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">else</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#9ea928;">// add WHERE key = value</span></p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; criteria.Add(<span style="color:#2bdad5;">Restrictions</span>.Eq(x.Key, x.Value));</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; });</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">return</span> criteria.List&lt;T&gt;() <span style="color:#ff7c05;">as</span> <span style="color:#2bdad5;">List</span>&lt;T&gt;;</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></span></div>
<p><!--EndFragment--></p>
<p><span style="color:#ff7c05;"><font color="#dbe387"></font><font color="#000000">Here&rsquo;s my (now) passing test that I used to test this logic as I built it:</font></span></p>
<p><span style="color:#ff7c05;"><font color="#dbe387"></p>
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<div style="font-family:Monaco, Consolas;background:#383838;color:#dbe387;font-size:8pt;">
<p style="margin:0;">[<span style="color:#2bdad5;">Fact</span>]</p>
<p style="margin:0;"><span style="color:#ff7c05;">public</span> <span style="color:#ff7c05;">void</span> can_find_students_by_array_of_student_ids()</p>
<p style="margin:0;">{</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> studentsToFind = <span style="color:#ff7c05;">new</span> <span style="color:#ff7c05;">int</span>[] { <span style="color:aqua;font-weight:bold;">622100</span>, <span style="color:aqua;font-weight:bold;">567944</span>, <span style="color:aqua;font-weight:bold;">601466</span> };</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> criteria = <span style="color:#ff7c05;">new</span> <span style="color:#2bdad5;">Dictionary</span>&lt;<span style="color:#ff7c05;">string</span>, <span style="color:#ff7c05;">object</span>&gt;();</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; criteria.Add(<span style="background:#6f0205;color:white;">&#8220;Id&#8221;</span>, studentsToFind);</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; criteria.Add(<span style="background:#6f0205;color:white;">&#8220;Grade&#8221;</span>, <span style="background:#6f0205;color:white;">&#8220;09&#8243;</span>);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> sut = <span style="color:#ff7c05;">new</span> <span style="color:#2bdad5;">StudentRepository</span>();</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; <span style="color:#ff7c05;">var</span> students = sut.FindAll(criteria);</p>
<p style="margin:0;">&nbsp;</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; students.Count.ShouldBeEqualTo(<span style="color:aqua;font-weight:bold;">1</span>);</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; students.ShouldContainMatching(x =&gt; x.Id == <span style="color:aqua;font-weight:bold;">567944</span>);</p>
<p style="margin:0;">&nbsp;&nbsp;&nbsp; students.ForEach(x =&gt; </p>
<p style="margin:0;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#2bdad5;">Console</span>.WriteLine(<span style="background:#6f0205;color:white;">&#8220;{0}, {1}&#8221;</span>.AsFormatFor(x.FullName, x.Id)));</p>
<p style="margin:0;">}</p>
</div>
<p><!--EndFragment--></div>
<p><!--EndFragment--></font></span></p>
<p><span style="color:#ff7c05;"><font color="#dbe387"></font><font color="#000000">Test Passed.&nbsp; Woot.&nbsp; The generated SQL is also nice and clean (really loving NHProf&hellip; though I trimmed out the excess columns for brevity).</font></span></p>
<p><span style="color:#ff7c05;"><font color="#dbe387"><span><font size="3"></font><font face="Calibri"></p>
<p style="margin:0;" class="MsoNoSpacing"><span style="font-family:Consolas;font-size:9pt;"><font color="#000000">SELECT this_.Id<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>as Id7_0_, [..]</font></span></p>
<p style="margin:0;" class="MsoNoSpacing"><span style="font-family:Consolas;font-size:9pt;"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>this_.Grade<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>as Grade7_0_, [..]</font></span></p>
<p style="margin:0;" class="MsoNoSpacing"><span style="font-family:Consolas;font-size:9pt;"><font color="#000000">FROM<span>&nbsp;&nbsp;&nbsp;</span>custom.student_lkup this_</font></span></p>
<p style="margin:0;" class="MsoNoSpacing"><span style="font-family:Consolas;font-size:9pt;"><font color="#000000">WHERE<span>&nbsp; </span>this_.Id in (622100 /* :p0 */,567944 /* :p1 */,601466 /* :p2 */)</font></span></p>
<p style="margin:0;" class="MsoNoSpacing"><span style="font-family:Consolas;font-size:9pt;"><font color="#000000"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>and this_.Grade = 09 /* :p3 */</font></span></p>
<p></font></span></font></span>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/sharp+architecture">sharp+architecture</a>, <a rel="tag" href="http://technorati.com/tag/nhibernate">nhibernate</a>, <a rel="tag" href="http://technorati.com/tag/sql">sql</a>, <a rel="tag" href="http://technorati.com/tag/patterns">patterns</a>, <a rel="tag" href="http://technorati.com/tag/c#">c#</a>, <a rel="tag" href="http://technorati.com/tag/fluent+nhibernate">fluent+nhibernate</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/879/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/879/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/879/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/879/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/879/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/879/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/879/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/879/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/879/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/879/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=879&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/08/performing-select-where-in-using-a-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Comparing Google and Bing</title>
		<link>http://tiredblogger.wordpress.com/2009/06/01/comparing-google-and-bing/</link>
		<comments>http://tiredblogger.wordpress.com/2009/06/01/comparing-google-and-bing/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 21:17:16 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Everything Else]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/06/01/comparing-google-and-bing/</guid>
		<description><![CDATA[Bing, the latest iteration of Windows Live Search, is now available for use and has been getting quite a few rave reviews.&#160; Miguel Carrasco wrote a lengthy post discussing the benefits of Bing over Google; however, maybe I&#8217;m old fashioned, but I see a lot of the hype as overhead.
Not to nitpick, but searching DIRECTLY [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=877&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Bing, the latest iteration of Windows Live Search, is now available for use and has been getting quite a few rave reviews.&nbsp; Miguel Carrasco wrote a <a href="http://www.realsoftwaredevelopment.com/an-inside-look-at-bing/" target="_blank">lengthy post</a> discussing the benefits of Bing over Google; however, maybe I&rsquo;m old fashioned, but I see a lot of the hype as overhead.</p>
<p>Not to nitpick, but searching DIRECTLY for product names will return advertisements and sponsored sales information&mdash;no matter the search engine.&nbsp; Miguel&rsquo;s post (searching for a Nikon D60 camera).&nbsp; Using my new fanboy item, the Palm Pre, as an example, I can see that the Google page actually has FEWER (real estate)&nbsp;&ldquo;advertisements&rdquo; than the Bing search.</p>
<p><strong>Bing</strong> has a whopping 6 sponsored links&hellip; along with something called Bing cashback that I haven&rsquo;t really read up on yet.&nbsp; That along witht he lost space on the left seems like a lot of waste.</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=527"><img style="width:546px;height:428px;" border="2" hspace="5" alt="Bing" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=527" width="644" height="525" /></a></font></p>
<p><strong>Google </strong>drops off a bit of space for the 3 sponsored links, but keeps it thin and uses it&rsquo;s integration with YouTube to show previews and group the video results to the top.</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=528"><img style="width:549px;height:374px;" border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=528" width="612" height="414" /></a></font></p>
<p>BUT&hellip; how much does that matter?&nbsp; If Google&rsquo;s page takes a moment more to load, do the background graphics, fancy headers, and AJAX postbacks on the Bing page make up that difference?</p>
<p><strong>&ldquo;Previews&rdquo; in Google and Bing</strong></p>
<p>An exciting point with Bing is the content previews.&nbsp; Hover over a search result and it provides a bit more information.&nbsp; This, however, has been in Google&rsquo;s search for quite a while if you turn on the functionality.</p>
<p>I&rsquo;ll admit, I like the hover effect.&nbsp; Clean, renders relatively quickly (noticed a bit of delay on some pages, but not too bad), and seems to parse content well.&nbsp; But is it ground breaking?&nbsp; Nah, not really.</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=529"><img style="width:572px;height:198px;" border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=529" width="571" height="231" /></a></font></p>
<p>Google&rsquo;s had it for a while, though I&rsquo;ll admit, I rarely use it (I used it more while doing heavy research in school).</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=530"><img border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=530" width="575" height="262" /></a></font></p>
<p>The difference is that Google&rsquo;s requires you to turn it on&hellip; For those who don&rsquo;t use it, the dynamic filtering is FANTASTIC (and provides that handy &ldquo;left side bar&rdquo; that Bing is raving about).&nbsp; Remember&mdash;Google was originally focused on extremely streamlined results&mdash;&rdquo;more text&rdquo; and AJAX postbacks would be considered evil. <img src='http://s.wordpress.com/wp-includes/images/smilies/face-wink.png' alt=';)' class='wp-smiley' /> </p>
<p>If you really do need more images, using Google&rsquo;s &ldquo;Images on the page&rdquo; provides a cool look at what graphics are on the page.</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=531"><img border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=531" width="574" height="360" /></a></font></p>
<p><strong>Are product searches always what we do?&nbsp; Nah!</strong></p>
<p>How often do we actually search for a product name&mdash;especially in the workplace?&nbsp; When I&rsquo;m looking for my Pre, sure, but 90% of the day is spent searching for error messages, code snippets, and forum messages.&nbsp; Face it, I <a href="http://is.gd/LMha" target="_blank">JFGI</a> it all day long. I encourage coworkers to JFGI. Etc.</p>
<p>So how does Bing and Google stack up when searching for a less commercial, more technical request?&nbsp; I&rsquo;ve recently dug into <a href="http://www.db4o.com/" target="_blank">db40</a>&nbsp;and needed to dig up some ideas for id generation.&nbsp; I remember reading a blog post recently about it, but couldn&rsquo;t remember who wrote it.</p>
<p>Bing returned an interesting result set&hellip; but didn&rsquo;t turn up (in the first 10) what I was looking for&hellip; </p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=532"><img style="width:573px;height:488px;" border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=532" width="658" height="539" /></a></font></p>
<p>Nearly all of the results were root domains or directories&mdash;nothing real specific (blog posts, forum posts, etc) from the titles.&nbsp; Since the cool Bing &ldquo;sorting and grouping&rdquo; doesn&rsquo;t appear to apply to everything quiet yet (not sure if that&rsquo;s context-based or a newness/lack of indexing), I was left with &ldquo;all results&rdquo;.</p>
<p>On the other hand, Google appears to put more priority on the title of the page.&nbsp; Notice on the Bing search results, &ldquo;Id Generation&rdquo; didn&rsquo;t appear in ANY of the page titles whereas they&rsquo;re in all of the titles of the Google results.</p>
<p><font color="#0066cc"><a href="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=533"><img border="2" hspace="5" alt="" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=533" width="563" height="490" /></a></font></p>
<p><strong>The title doesn&rsquo;t mean these are the BEST results</strong>; however, with news stories, blog posts, etc&mdash;the takeaway point will usually be in the title.&nbsp; </p>
<p>The blog post I was wanting showed up second in the Google results.&nbsp; The Bing results referenced Tuna&rsquo;s blog a few places; however, didn&rsquo;t actually reference the post for &ldquo;Id Generation in db4o&rdquo;.&nbsp; The one time it WAS mentioned (the 4th result of Bing), it was a stale link to the front page of Tuna&rsquo;s blog&mdash;not the actual post.</p>
<p><strong><u>Conclusion</u></strong></p>
<p>The selling point to Google for many years now has been two fold:</p>
<p>1) Extremely clean, fast user interface<br />2) Reliable and relevant&nbsp;results</p>
<p>I moved away from AltaVista, Yahoo, and other engines years ago because they wanted to be &lsquo;cute&rsquo; and while Bing has potential, it&rsquo;s already too cute for my tastes without any real benefit.</p>
<p>It&rsquo;ll be interesting to see how Bing grows&mdash;and how it affects Google.&nbsp; It&rsquo;s too early, however, to say that Bing is this saving grace&mdash;especially if you&rsquo;ve never dug into all of the features of Google.</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/Bing">Bing</a>, <a rel="tag" href="http://technorati.com/tag/Google">Google</a>, <a rel="tag" href="http://technorati.com/tag/search+engine">search+engine</a>, <a rel="tag" href="http://technorati.com/tag/comparison">comparison</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/877/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=877&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/06/01/comparing-google-and-bing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=527" medium="image">
			<media:title type="html">Bing</media:title>
		</media:content>

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=528" medium="image" />

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=529" medium="image" />

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=530" medium="image" />

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=531" medium="image" />

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=532" medium="image" />

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=533" medium="image" />
	</item>
		<item>
		<title>Configuring Oracle SQL Developer for Windows 7</title>
		<link>http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/</link>
		<comments>http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/#comments</comments>
		<pubDate>Fri, 29 May 2009 15:55:42 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Hardware and Software]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/</guid>
		<description><![CDATA[I&#8217;m fully Vista-free now and loving it; however, Oracle SQL Developer has (once again) decided to simply be annoying to configure.
&#60;rant&#62;Yes, I realize Oracle hates Microsoft.&#160; Girls, you&#8217;re both pretty&#8212;please grow up.&#60;/rant&#62;
Anyway, after a bit of hunting, I think I&#8217;ve found a good mix for those of us who love SQL Developer for coding and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=875&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&rsquo;m fully Vista-free now and loving it; however, Oracle SQL Developer has (once again) decided to simply be annoying to configure.</p>
<p>&lt;rant&gt;Yes, I realize Oracle hates Microsoft.&nbsp; Girls, you&rsquo;re both pretty&mdash;please grow up.&lt;/rant&gt;</p>
<p>Anyway, after a bit of hunting, I think I&rsquo;ve found a good mix for those of us who love SQL Developer for coding and testing, but don&rsquo;t &ldquo;use&rdquo; a lot of the Oracle proprietary <strike>junk</strike> features that comes with it.</p>
<p>Originally, I was going to include a couple of the configuration files; however, they&rsquo;re spread out EVERYWHERE and, frankly, I can&rsquo;t find them all. <img src='http://s.wordpress.com/wp-includes/images/smilies/face-sad.png' alt=':(' class='wp-smiley' /> &nbsp; I also can&rsquo;t figure out a way to import settings (without blowing my settings away first).</p>
<p><strong><u>File Paths</u></strong></p>
<p>As I mentioned before, some of the configuration files are spread out&mdash;everywhere.&nbsp; Here&rsquo;s where the most common files are located.</p>
<p><strong>sqldeveloper.conf </strong>&ndash; &lt;sqldeveloper folder&gt;\sqldeveloper\bin\</p>
<p><strong>ide.conf &ndash; </strong>&lt;sqldeveloper folder&gt;\ide\bin\</p>
<p><strong>User-Configured Settings </strong>&ndash; %appdata%\SQL Developer\</p>
<p>I prefer to make my modifications in sqldeveloper.conf; however, a lot of the resources that pop up on Google make them in ide.conf.&nbsp; Why?&nbsp; I&rsquo;m not sure.&nbsp; sqldeveloper.conf simply CALLS ide.conf.&nbsp; Meh.</p>
<p><strong><u>Fixing Memory Consumption on Minimize</u></strong></p>
<p>I found a <a href="http://java2go.blogspot.com/2007/06/jdeveloper-tips-2-fine-tuning.html" target="_blank">reference to JDeveloper</a> (another Java utility) that discussed how JDeveloper (and similarly, SQL Developer) pages everything when you minimize the window.</p>
<p>To fix this, open up <strong>sqldeveloper.conf</strong> and add the following line:</p>
<blockquote>
<p>AddVMOption -Dsun.awt.keepWorkingSetOnMinimize=true</p>
</blockquote>
<p><strong><u>Fixing Aero Basic Theme</u></strong></p>
<p>Tired of your IDE swapping back to Aero Basic whenever you launch SQL Developer?&nbsp; Me too.&nbsp; For now, Oracle reports that SQL Developer doesn&rsquo;t support the full Aero Theme&hellip; or does it?</p>
<p>To enable Aero support (or at least keep it from bouncing back to Aero Basic), open up <strong>sqldeveloper.conf </strong>and add the following line:</p>
<blockquote>
<p>AddVMOption -Dsun.java2d.noddraw=true</p>
</blockquote>
<p dir="ltr">The Oracle forums also recommend trying the following line:</p>
<blockquote>
<p dir="ltr">AddVMOption -Dsun.java2d.ddoffscreen=false</p>
</blockquote>
<p dir="ltr">That option; however, never resolved the issue for me.&nbsp; Your mileage may vary.</p>
<p dir="ltr"><strong><u>Cleaning Up The UI</u></strong></p>
<p dir="ltr">The default UI leaves a lot to be desired for Oracle SQL Developer.&nbsp; Here&rsquo;s a few UI tips to try out.&nbsp; These settings are found under Tools &gt; Preferences.</p>
<p dir="ltr"><u>Change the Theme</u> &ndash; Environment &gt; Theme.&nbsp; </p>
<p dir="ltr">I like <strong>Experience Blue</strong>.&nbsp; It&rsquo;s clean, simple, and goes well with Windows 7&rsquo;s look and feel.</p>
<p dir="ltr"><u>Change Fonts</u> &ndash; Code Editor &gt; &hellip;</p>
<p dir="ltr">There are quite a few fonts that can be configured.&nbsp; Here&rsquo;s what I changed:</p>
<p dir="ltr">Code Insight &ndash; Segoe UI, 12<br />Display &ndash; check &lsquo;Enable Text Anti-Aliasing&rsquo;<br />Fonts &ndash; Consolas, 11<br />Printing &ndash; Consolas, 10</p>
<p dir="ltr"><u>Disable Unnecessary Extensions</u> &ndash; Extensions &gt; &hellip;</p>
<p dir="ltr">Honestly, I don&rsquo;t use ANY of the extentions, so I disabled everything as well as unchecking &lsquo;Automatically Check for Updates&rsquo;.&nbsp; I&rsquo;ve noticed that load time for the UI is insanely fast now (well, insanely fast for a Java app on Windows).</p>
<p dir="ltr"><u>Window Locations</u></p>
<p dir="ltr">The only thing that I can&rsquo;t figure out how to fix is the window location and placement.&nbsp; Example: When you open a new worksheet, the results area is not visible (you have to drag that frame up each time).&nbsp; That annoys me to no end and I can&rsquo;t find a place to &lsquo;save current window layout&rsquo; or similar.&nbsp; Ideas?</p>
<p dir="ltr"><strong><u>That&rsquo;s it!</u></strong></p>
<p dir="ltr">With that, SQL Developer loads up quickly, connects, and displays just fine in Windows 7.</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/Oracle">Oracle</a>, <a rel="tag" href="http://technorati.com/tag/Raptor">Raptor</a>, <a rel="tag" href="http://technorati.com/tag/Oracle+SQL+Developer">Oracle+SQL+Developer</a>, <a rel="tag" href="http://technorati.com/tag/Windows+7">Windows+7</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/875/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/875/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/875/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/875/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/875/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/875/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/875/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/875/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/875/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/875/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=875&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2010 &amp; .NET Framework 4.0 Beta 1 Out</title>
		<link>http://tiredblogger.wordpress.com/2009/05/18/visual-studio-2010-net-framework-4-0-beta-1-out/</link>
		<comments>http://tiredblogger.wordpress.com/2009/05/18/visual-studio-2010-net-framework-4-0-beta-1-out/#comments</comments>
		<pubDate>Mon, 18 May 2009 18:05:27 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net 4.0]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/05/18/visual-studio-2010-net-framework-4-0-beta-1-out/</guid>
		<description><![CDATA[For MSDN Subscribers, VS2010 and .NET 4.0 beta 1 have hit the downloads site.
After reading through Microsoft&#8217;s &#8220;Overview&#8221; page&#8212;my biggest hope is that it doesn&#8217;t do &#8220;too much&#8221;.&#160; Visual Studio is already a monolith of hard drive cranking pain as it is.&#160; My Cray is still being held up by our purchasing department&#8212;I hope I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=873&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>For MSDN Subscribers, VS2010 and .NET 4.0 beta 1 have hit the <a href="http://is.gd/B3pn" target="_blank">downloads site</a>.</p>
<p>After reading through Microsoft&rsquo;s &ldquo;Overview&rdquo; page&mdash;my biggest hope is that it doesn&rsquo;t do &ldquo;too much&rdquo;.&nbsp; Visual Studio is already a monolith of hard drive cranking pain as it is.&nbsp; My Cray is still being held up by our purchasing department&mdash;I hope I don&rsquo;t need it.&nbsp; Maybe they took Win7&rsquo;s approach that less is more and trimmed things down?</p>
<p>Overview: <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx</a></p>
<p>Beta Docs: <a href="http://msdn.microsoft.com/en-us/library/dd831853(VS.100).aspx">http://msdn.microsoft.com/en-us/library/dd831853(VS.100).aspx</a></p>
<p>The biggest point of interest (so far, I mean&mdash;it&rsquo;s still downloading) is the warning for Win7 RC:</p>
<blockquote>
<p><span><br />
<tr>
<td style="border-left:rgb(204,204,204) 1px solid;" width="50%" valign="top"></td>
</tr>
<tr>
<td style="border-left:rgb(204,204,204) 1px solid;" colspan="4"><span class="FilesDetailsInfoText">NOTE: If you are installing Visual Studio 2010 Beta 1 on Windows 7 RC, you may receive a compatibility warning when installing SQL Server 2008. For more information and a workaround, please click <a href="http://go.microsoft.com/fwlink/?LinkId=151637">here</a>.</span></td>
</tr>
<p></span></p>
</blockquote>
<p>The link, however, sends you to an explaination of the error&mdash;which is simply that Win7 RC requires SQL Server 2008 SP1 or 2005 SP3.&nbsp; If I remember right, I <strong><u>thought</u></strong> the error message SAID that.&nbsp; I guess Microsoft is just covering all of the bases.</p>
<p>Finally, it looks like the &ldquo;official&rdquo; tag on Twitter is <a href="http://twitter.com/#search?q=%23vs10" target="_blank">#vs10</a>; however, quite a few of us have been using <a href="http://twitter.com/#search?q=%23vs2010" target="_blank">#vs2010</a>.&nbsp; Follow both for the full scope.</p>
<p>I&rsquo;ve got about 20 minutes left on the download and a VM waiting for this to be loaded.&nbsp; More to come!</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/visual+studio+2010">visual+studio+2010</a>, <a rel="tag" href="http://technorati.com/tag/.net+4.0">.net+4.0</a>, <a rel="tag" href="http://technorati.com/tag/vs10">vs10</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/873/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/873/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/873/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=873&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/05/18/visual-studio-2010-net-framework-4-0-beta-1-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing Streaming In Windows 7 (.asx Files)</title>
		<link>http://tiredblogger.wordpress.com/2009/05/18/fixing-streaming-in-windows-7-asx-files/</link>
		<comments>http://tiredblogger.wordpress.com/2009/05/18/fixing-streaming-in-windows-7-asx-files/#comments</comments>
		<pubDate>Mon, 18 May 2009 13:18:15 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Hardware and Software]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://tiredblogger.wordpress.com/2009/05/18/fixing-streaming-in-windows-7-asx-files/</guid>
		<description><![CDATA[After tolerating the issue for all of the last beta and since installing RC, I decided to dedicate sometime into it this afternoon to research the cause and look for a fix.
The problem:
When attempting to play any .asx streaming playlist file, Windows would report that it could not locate the stream.
&#8220;Windows Media Player cannot play [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=871&subd=tiredblogger&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>After tolerating the issue for all of the last beta and since installing RC, I decided to dedicate sometime into it this afternoon to research the cause and look for a fix.</p>
<p><b>The problem:</b></p>
<p>When attempting to play any .asx streaming playlist file, Windows would report that it could not locate the stream.</p>
<p><b>&ldquo;Windows Media Player cannot play the file.&nbsp; The Player might not support the file type or might not support the codec that was used to compress the file.&rdquo;</b></p>
<p><img border="2" hspace="5" alt="WMP12 Streaming Error Image" vspace="5" src="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=522" /></p>
<p>The initial response (usually) to this is that the codec is missing or corrupted.&nbsp; I think I tried almost every possible of codecs around&#8211;no dice.</p>
<p><b>The fix:</b></p>
<p>A bit of registry &#8220;checking&#8221; is in order.&nbsp; There are four keys I updated:</p>
<p>[HKEY_CLASSES_ROOT\.avi]<br />@=&#8221;WMP11.AssocFile.AVI&#8221;</p>
<p>[HKEY_CLASSES_ROOT\.asf]<br />@=&#8221;WMP11.AssocFile.ASF&#8221;</p>
<p>[HKEY_CLASSES_ROOT\.asx]<br />@=&#8221;WMP11.AssocFile.ASX&#8221;</p>
<p>[HKEY_CLASSES_ROOT\.wmv]<br />@=&#8221;WMP11.AssocFile.WMV&#8221;</p>
<p><i><b>Note: The @= equates to the (Default) value.</b></i></p>
<p>Browse the web to a streaming source (I used <a id="j1bk" title="Solo Piano Radio" href="http://is.gd/ALTV" target="_blank">Solo Piano Radio</a>&#8211;calm, relaxing music while reading and such) and launch the streaming link.&nbsp; It should work like a champ&#8211;like it has for years.</p>
<p>So far I&rsquo;ve implemented this on three different computers with Windows 7&ndash;-so far, so good.</p>
<p><b>Resources: </b></p>
<p>According to the official <a id="z7dg" title="Microsoft Windows 7 (Media)" href="http://is.gd/ALQH" target="_blank">Microsoft Windows 7 (Media)</a> forums, it seems one of the Windows Live installers is to blame; however, if you catch the verbiage, they seem to relate it to another vendor.&nbsp; I wonder if &#8220;vendor&#8221; without much more of a second thought.&nbsp; </p>
<p>The fact that this issue survived to RC shocks me; however, all things considered&mdash;Win7 is still running like a champ.</p>
<div class="bjtags">Tags: <a rel="tag" href="http://technorati.com/tag/Windows+7">Windows+7</a>, <a rel="tag" href="http://technorati.com/tag/asx">asx</a>, <a rel="tag" href="http://technorati.com/tag/streaming">streaming</a>, <a rel="tag" href="http://technorati.com/tag/wmp12">wmp12</a></div>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tiredblogger.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tiredblogger.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tiredblogger.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tiredblogger.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tiredblogger.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tiredblogger.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tiredblogger.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tiredblogger.wordpress.com/871/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tiredblogger.wordpress.com/871/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tiredblogger.wordpress.com/871/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tiredblogger.wordpress.com&blog=253870&post=871&subd=tiredblogger&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://tiredblogger.wordpress.com/2009/05/18/fixing-streaming-in-windows-7-asx-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/31657c007e961f2f893c8b8ee594754a?s=96&amp;d=identicon&amp;r=G" medium="image">
			<media:title type="html">tiredstudent</media:title>
		</media:content>

		<media:content url="http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&amp;id=522" medium="image">
			<media:title type="html">WMP12 Streaming Error Image</media:title>
		</media:content>
	</item>
	</channel>
</rss>
