<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Marcin Obel &#187; Marcin Obel</title>
	<atom:link href="http://marcinobel.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://marcinobel.com</link>
	<description>.NET, Windows 8, Windows Phone, ASP.NET MVC, Web API, jQuery, Test Driven Development, Agile</description>
	<lastBuildDate>Thu, 10 May 2012 10:31:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Aspy &#8211; ASP.NET Session and Cache viewer</title>
		<link>http://marcinobel.com/index.php/aspy-aspnet-session-cache-viewer/</link>
		<comments>http://marcinobel.com/index.php/aspy-aspnet-session-cache-viewer/#comments</comments>
		<pubDate>Thu, 10 May 2012 10:30:21 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=467</guid>
		<description><![CDATA[Today I&#8217;ve released new version of Aspy. For those of you who don&#8217;t know what it is I recommend to visit project&#8217;s website at: http://bytecarrot.com/aspy/. I short words it is the ASP.NET Session and Cache viewer in a form of ASP.NET HTTP handler. Current, 1.1.0 version is not a big changes but contains a feature [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-468" style="margin-right: 15px; margin-bottom: 5px; border-style: initial; border-color: initial; border-image: initial; border-width: 0px;" title="Aspy" src="http://marcinobel.com/wp-content/uploads/Aspy.png" alt="" width="150" height="150" />Today I&#8217;ve released new version of <strong>Aspy</strong>. For those of you who don&#8217;t know what it is I recommend to visit project&#8217;s website at:</p>
<p><a href="http://bytecarrot.com/aspy/"><strong>http://bytecarrot.com/aspy/</strong></a>. </p>
<p>I short words it is the <strong>ASP.NET Session and Cache viewer</strong> in a form of ASP.NET HTTP handler.</p>
<p>Current, <strong>1.1.0</strong> version is not a big changes but contains a feature requested by people who have started to use Aspy in theirs projects. The biggest problem with previous release was in viewing large values. There is no possibility to display for instance big XML in a table cell so the value was always truncated. Right now hovering at value cell shows small magnifying glass which clicked shows popup window with whole value. In addition from now ByteCarrot.Aspy.dll is signed and has strong name so it can be used with other signed assemblies.</p>
<p>More information, download and installation instructions can be found on <strong>Aspy website</strong> mentioned above. Below I&#8217;ve added screenshots presenting new feature added in this new version.</p>
<p><img class="aligncenter size-full wp-image-469" title="Aspy 1.1.0" src="http://marcinobel.com/wp-content/uploads/Aspy.1.1.0.jpg" alt="" width="630" height="346" /></p>
<p><img class="aligncenter size-full wp-image-470" title="Aspy 1.1.0" src="http://marcinobel.com/wp-content/uploads/Aspy.1.1.0-2.jpg" alt="" width="630" height="540" /></p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/aspy-aspnet-session-cache-viewer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Saving place with jQuery and CSS based hover / context menu</title>
		<link>http://marcinobel.com/index.php/saving-place-jquery-css-based-hover-context-menu/</link>
		<comments>http://marcinobel.com/index.php/saving-place-jquery-css-based-hover-context-menu/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 11:10:12 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=434</guid>
		<description><![CDATA[Monitors and theirs resolutions are getting bigger and bigger, but there is always a problem where to put all buttons, links and other controls to avoid overwhelmed UI. I am big fan of clean UI without unnecessary things used only from time to time. By default on screen should contain only the core information without distracting [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-406 alignleft" style="margin-right: 10px;" title="jQuery UI" src="http://marcinobel.com/wp-content/uploads/jquery-ui.png" alt="" width="275" height="81" />Monitors and theirs resolutions are getting bigger and bigger, but there is always a problem where to put all buttons, links and other controls to avoid overwhelmed UI. I am big fan of clean UI without unnecessary things used only from time to time. By default on screen should contain only the core information without distracting buttons, switches and things like that. Unfortunately all these additional stuff is required to work with an application so has to be implemented. The trickiest part is to make is available but in a subtle way.</p>
<p>I had such problem working on the last version of WebConsole. My solution is quite trivial and required a little bit of jQuery and CSS. I&#8217;ve solved the problem using as I call it &#8220;action menus&#8221;. These are context menu but activated by hovering mouse not right click. You can check how such &#8220;action menu&#8221; works in a screencast available below.</p>
<div style="text-align: center;"><iframe src="http://www.youtube.com/embed/Y7CZwu-3XZk" frameborder="0" width="560" height="315"></iframe></div>
<p>All three &#8220;action menus&#8221; presented in screencast above have the same HTML structure and use the same jQuery script. The look &amp; feel has been totally customized in CSS so it is very useful and simple to use thing.</p>
<p>General structure of &#8220;action menu&#8221; and base CSS definition show two snippets below.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;account-menu&quot; class=&quot;action-menu&quot;&gt;
    &lt;span&gt;Welcome &lt;strong&gt;Administrator&lt;/strong&gt;!&lt;/span&gt;
    &lt;ul class=&quot;children&quot;&gt;
        &lt;li class=&quot;nowrap-text&quot;&gt;&lt;a href=&quot;#&quot;&gt;Change Password&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Sign Out&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</pre>
<pre class="brush: css; title: ; notranslate">
div.action-menu {
    position: relative;
    margin: 0px;
    padding: 0px;
}

div.action-menu * {
    margin: 0px;
    padding: 0px;
}

div.action-menu a {
    text-decoration: none;
}

div.action-menu ul {
    list-style: none;
    display: none;
    position: absolute;
    z-index: 9999;
}
</pre>
<p>jQuery executed to make &#8220;action menu&#8221; reacting to hover is also very simple and straightforward.</p>
<pre class="brush: jscript; title: ; notranslate">
// Adds action menu
function addActionMenus() {
    $('div.action-menu').hover(
        function () {
            $(this).addClass('hover');
            $(this).find('ul').show();
        },
        function () {
            $(this).removeClass('hover');
            $(this).find('ul').hide();
        }
    );
}

jQuery(function () {
    addActionMenus();
});
</pre>
<p>As I mentioned before rest of customization is done in CSS. The demo from screencast contains all code presented above and customizations made for each menu presented there. I am sharing it with you with hope it will be useful. You can download it <a href="http://marcinobel.com/wp-content/uploads/actionmenu.zip"><strong>here</strong></a>.</p>
<p>Please, let me know what do you think about this type of hiding actions available only in a particular contexts and my simple implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/saving-place-jquery-css-based-hover-context-menu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery UI tabs with vertical navigation</title>
		<link>http://marcinobel.com/index.php/jquery-ui-tabs-vertical-navigation/</link>
		<comments>http://marcinobel.com/index.php/jquery-ui-tabs-vertical-navigation/#comments</comments>
		<pubDate>Sun, 18 Mar 2012 16:41:22 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=405</guid>
		<description><![CDATA[I am currently working on a settings view for the WebConsole application. This view will consist of many smaller views for editing configuration. I am using jQuery UI is the obvious choice for me was Tabs control available in this library. Unfortunately I was not very happy with its default layout. The problem was that [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-406" style="margin-right: 10px;" title="jQuery UI" src="http://marcinobel.com/wp-content/uploads/jquery-ui.png" alt="" width="275" height="81" />I am currently working on a settings view for the <strong><a title="WebConsole" href="http://bytecarrot.com/webconsole/">WebConsole</a></strong> application. This view will consist of many smaller views for editing configuration. I am using <strong><a title="jQuery UI" href="http://jqueryui.com" target="_blank">jQuery UI</a></strong> is the obvious choice for me was <strong><a title="jQuery UI Tabc control" href="http://jqueryui.com/demos/tabs/" target="_blank">Tabs control available in this library</a></strong>. Unfortunately I was not very happy with its default layout. The problem was that my main menu is laid out horizontally so I wanted to distinguish somehow tabs which are just below it. I have solved it changing navigation in tabs from horizontal to vertical. Fortunately it turned out very easy and required only some CSS. Below I am presenting the result, CSS and HTML/Razor source code.</p>
<p><strong>jQuery UI tabs with vertical navigation</strong></p>
<p><img class="size-full wp-image-410 alignnone" title="jQuery UI tabs with vertical navigation" src="http://marcinobel.com/wp-content/uploads/jQuery-UI-tabs.png" alt="" width="605" height="613" /></p>
<p><strong>HTML/Razor source code</strong></p>
<pre class="brush: xml; title: ; notranslate">
@model ByteCarrot.WebConsole.Web.Controllers.Settings.SettingsViewModel&lt;/pre&gt;
&lt;div id=&quot;settings&quot;&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;@Url.Action(MVC.Account.List())&quot;&gt;Users&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;@Url.Action(MVC.Account.List())&quot;&gt;Settings 1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;@Url.Action(MVC.Account.List())&quot;&gt;Settings 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
     $(function () {
         $(&quot;#settings&quot;).tabs();
     });
&lt;/script&gt;
</pre>
<p><strong>CSS source code</strong></p>
<pre class="brush: css; title: ; notranslate">
div#settings {
    position: relative;
    padding-left: 200px;
}

div#settings &gt; div {
    min-height: 300px;
}

div#settings .ui-tabs-nav {
    position: absolute;
    left: 0px;
    top: 0px;
    bottom: 0px;
    width: 200px;
    padding: 5px 0px 5px 5px;
}

div#settings .ui-tabs-nav li {
    left: 0px;
    width: 195px;
    border-right: none;
    overflow: hidden;
    margin-bottom: 2px;
}

div#settings .ui-tabs-nav li a {
    float: right;
    width: 100%;
    text-align: right;
}

div#settings .ui-tabs-nav li.ui-tabs-selected {
    border: none;
    border-right: solid 1px #fff;
    background: none;
    background-color: #fff;
    width: 200px;
}
</pre>
<p>If you are fan of <a title=".less" href="http://www.dotlesscss.org/" target="_blank">.<strong>less</strong></a> project here is the same CSS in LESS format:</p>
<pre class="brush: css; title: ; notranslate">
div#settings
{
    position: relative;
    padding-left: 200px;

    &gt; div
    {
        min-height: 300px;
    }

    .ui-tabs-nav
    {
        position: absolute;
        left: 0px;
        top: 0px;
        bottom: 0px;
        width: 200px;
        padding: 5px 0px 5px 5px;

        li
        {
            left:  0px;
            width: 195px;
            border-right: none;
            overflow: hidden;
            margin-bottom: 2px;

            a
            {
                float: right;
                width: 100%;
                text-align: right;
            }
        }

        li.ui-tabs-selected
        {
            border: none;
            border-right: solid 1px #fff;
            background: none;
            background-color: #fff;
            width: 200px;
        }
    }
}
</pre>
<p>I hope it will be useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/jquery-ui-tabs-vertical-navigation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fluent NHibernate &#8211; mapping one to one relation</title>
		<link>http://marcinobel.com/index.php/fluent-nhibernate-mapping-one-to-on-relation/</link>
		<comments>http://marcinobel.com/index.php/fluent-nhibernate-mapping-one-to-on-relation/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 07:32:38 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=380</guid>
		<description><![CDATA[Few weeks ago I&#8217;ve started new project based on ASP.NET MVC, jQuery and NHibernate. It has some part of functionality inspired by ELMAH but mainly goes in a different direction addressing some additional scenarios and it is called WebConsole. It is able to catch exceptions from ASP.NET application and save them with whole context in [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-210" style="margin-right: 10px;" title="Fluent NHibernate" src="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png" alt="" width="360" height="117" />Few weeks ago I&#8217;ve started new project based on ASP.NET MVC, jQuery and NHibernate. It has some part of functionality inspired by <a title="ELMAH" href="http://code.google.com/p/elmah/" target="_blank">ELMAH </a>but mainly goes in a different direction addressing some additional scenarios and it is called <strong><a title="ByteCarrot WebConsole" href="http://bytecarrot.com" target="_blank">WebConsole</a></strong>. It is able to catch exceptions from ASP.NET application and save them with whole context in centralized database. It can also log every request and response even if there was no exception. As you can see everything is spinning around HTTP request and response model.</p>
<p>In order to store information about HTTP communication I had to create NHibernate entities and map them to a database. After some short brainstorming I came up with three basic entities:</p>
<p><strong>Activity</strong> &#8211; representing single &#8220;act&#8221; of communication between a client and a server</p>
<pre class="brush: csharp; title: ; notranslate">
public class Activity : Entity
{
    // ... some properties and methods removed for readability

    public virtual int Id { get; set; }

    private Request _request;
    public virtual Request Request
    {
        get { return _request; }
    }

    public virtual void Add(Request request)
    {
        if (_request != null)
        {
            _request.Activity = null;
        }
        _request = request;
        _request.Activity = this;
    }

    private Response _response;
    public virtual Response Response
    {
        get { return _response; }
    }

    public virtual void Add(Response response)
    {
        if (_response != null)
        {
            _response.Activity = null;
        }
        _response = response;
        _response.Activity = this;
    }
}
</pre>
<p><strong>Request</strong> &#8211; representing request made by the client</p>
<pre class="brush: csharp; title: ; notranslate">
public class Request : Entity
{
    // ... some properties  and methods removed for readability

    public virtual int Id { get; set; }

    public virtual Activity Activity { get; set; }
}
</pre>
<p><strong>Response</strong> &#8211; representing response from the server</p>
<pre class="brush: csharp; title: ; notranslate">
public class Response : Entity
{
    // ... some properties  and methods removed for readability

    public virtual int Id { get; set; }

    public virtual Activity Activity { get; set; }
}
</pre>
<p>During one <strong>Activity</strong> there can be no more than one <strong>Request</strong> and <strong>Response</strong>. With this assumptions in mind I&#8217;ve started thinking how to map these relations using Fluent NHibernate. It was obvious for me that this are one to one relations, but turned out it is not so obvious how to map them. After some googling, playing with the code and a cup coffee I found right configuration which work nice.</p>
<p>From the Activity side relations has been mapped in a standard way by using HasOne method with some other modifiers for the access and lazy loading. One thing worth mention is Id mapping with automatically generated values.</p>
<pre class="brush: csharp; title: ; notranslate">
public sealed class ActivityMap : ClassMap
{
    public ActivityMap()
    {
        // ... some mappings removed for readability

        Id(x =&gt; x.Id);

        HasOne(x =&gt; x.Request).Access.CamelCaseField(Prefix.Underscore)
                .Cascade.All().LazyLoad();

        HasOne(x =&gt; x.Response).Access.CamelCaseField(Prefix.Underscore)
                .Cascade.All().LazyLoad();
    }
}
</pre>
<p>From the Request and the Response mapping side thing looks quite different. This is because I had to &#8220;tell&#8221; that Id should not be automatically generated but taken from the Activity. Additionally HasOne relation looks different because it has to act as a foreign key and be constrained to values of the Activitie&#8217;s identifier (Id).</p>
<pre class="brush: csharp; title: ; notranslate">
public sealed class RequestMap : ClassMap
{
    public RequestMap()
    {
        // ... some mappings removed for readability

        Id(x =&gt; x.Id).GeneratedBy.Foreign(&quot;Activity&quot;);

        HasOne(x =&gt; x.Activity).Constrained().ForeignKey();
    }
}

public sealed class ResponseMap : ClassMap
{
    public ResponseMap()
    {
        // ... some mappings removed for readability

        Id(x =&gt; x.Id).GeneratedBy.Foreign(&quot;Activity&quot;);

        HasOne(x =&gt; x.Activity).Constrained().ForeignKey();
    }
}
</pre>
<p>At the end we came up with a solution where the main entity is responsible for generating identifiers and all other entities in one to one relation use them as theirs primary and foreign keys.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/fluent-nhibernate-mapping-one-to-on-relation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# 4.0 Named Arguments &#8211; example usage</title>
		<link>http://marcinobel.com/index.php/csharp-4-0-named-arguments-usage/</link>
		<comments>http://marcinobel.com/index.php/csharp-4-0-named-arguments-usage/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 18:06:57 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=314</guid>
		<description><![CDATA[One of the new features introduced in C# 4.0 were named arguments. There was a lot of discussion in the Internet about them and theirs pros and cons. Of course named arguments can be abused like any other part of C# but I think that when used wisely are able to make your code more [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt="" width="240" height="74" />One of the new features introduced in C# 4.0 were <strong><a title="Named Arguments in C# 4.0" href="http://msdn.microsoft.com/en-us/library/dd264739.aspx" target="_blank">named arguments</a></strong>. There was a lot of discussion in the Internet about them and theirs pros and cons. Of course named arguments can be abused like any other part of C# but I think that when used wisely are able to make your code more readable and easier to understand without the knowledge what is hidden behind the scene. Few days ago I was working on integration tests for REST API exposed by a startup I am working on with my team. Each test required some &#8220;execution context&#8221; and a way to inform &#8220;infrastructure&#8221; that after execution whole environment should be cleaned up (e.g. database). Because I use NUnit as a runner the first idea that came to my mind was to utilize [SetUp] and [TearDown] methods. But after some prototyping I realized that the solution is hard to understand and obfuscates the tests. Next day after short chat with <a href="http://twitter.com/lesnikowski" target="_blank"><strong>@lesnikowski</strong></a> new idea popped into my mind: I can create &#8220;execution context&#8221; with lambdas and named arguments! The example below shows how I have changed the idea into real code.</p>
<pre class="brush: csharp; title: ; notranslate">
[Test]
public void Add_WhenInvokedShouldAddNewExternalAudioFolder()
{
    Execute(test: () =&gt;
    {
        var json = WebApiClient.ExternalAudioFolder.Add(&quot;My folder&quot;, &quot;My description&quot;);
        var message = json.DeserializeJson&lt;AddMessage&gt;();

        Assert.That(message.Result, Is.EqualTo(Message.Success));
    },
    inContextOf: Account.Basic,
    cleanUpAfter: true);
}
</pre>
<p>What do you think about the code above? Do you have any additional ideas how to improve readability of this &#8220;execution context&#8221;?</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/csharp-4-0-named-arguments-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluent NHibernate conventions II &#8211; example for enumerations</title>
		<link>http://marcinobel.com/index.php/fluent-nhibernate-conventions-ii-enumerations/</link>
		<comments>http://marcinobel.com/index.php/fluent-nhibernate-conventions-ii-enumerations/#comments</comments>
		<pubDate>Thu, 20 May 2010 14:25:36 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=306</guid>
		<description><![CDATA[Most of the time I do not have to touch Fluent NHibernate conventions I have created some time ago. But from time to time I find in mappings some common scenario which is a good candidate to become a convention. This time I found that every time I am mapping a property of enumeration type [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-210" style="margin-right: 10px;" title="Fluent NHibernate" src="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png" alt="" width="360" height="117" />Most of the time I do not have to touch <strong><a title="Fluent NHibernate" href="http://fluentnhibernate.org/" target="_blank">Fluent NHibernate</a></strong> conventions I have created some time ago. But from time to time I find in mappings some common scenario which is a good candidate to become a convention. This time I found that every time I am mapping a property of enumeration type I have to specify its length manually.</p>
<p>Because I hate redundant work I have defined a <strong>Fluent NHibernate convention</strong> presented below.</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Linq;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;

namespace ExampleConventions
{
    public class EnumColumnLengthConvention
        : IPropertyConvention, IPropertyConventionAcceptance
    {
        public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
        {
            criteria.Expect(x =&gt; x.Property.PropertyType.IsEnum)
                .Expect(x =&gt; x.Length == 0);
        }

        public void Apply(IPropertyInstance instance)
        {
            var names = Enum.GetNames(instance.Property.PropertyType);
            instance.Length(names.Max(name =&gt; name.Length));
        }
    }
}
</pre>
<p>The convention is really simple. Its whole logic can be found in Apply method and I think it is self explanatory so there is nothing to describe here.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/fluent-nhibernate-conventions-ii-enumerations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[BUG] invalid exec_format &#8220;ir&#8221;, no %s</title>
		<link>http://marcinobel.com/index.php/bug-invalid-exec_format-ir/</link>
		<comments>http://marcinobel.com/index.php/bug-invalid-exec_format-ir/#comments</comments>
		<pubDate>Tue, 11 May 2010 07:03:44 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=288</guid>
		<description><![CDATA[Today I&#8217;ve switched from the default, C based implementation of Ruby to new version of IronRuby (1.0). After installation I wanted to update gems, install rake tool and of course at this point problems started. Command for updating gems displayed below: produced output like this: After some research turned out that RubyGems assumes that Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve switched from the default, C based implementation of <strong>Ruby</strong> to new version of <strong>IronRuby</strong> (1.0). After installation I wanted to update <strong>gems</strong>, install <strong>rake</strong> tool and of course at this point problems started. Command for updating <strong>gems</strong> displayed below:</p>
<pre class="brush: php; title: ; notranslate">
igem update --system
</pre>
<p>produced output like this:</p>
<pre class="brush: php; title: ; notranslate">
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.6
Updating RubyGems to 1.3.6
Installing RubyGems 1.3.6
ERROR:  While executing gem ... (Gem::Exception)
       [BUG] invalid exec_format &quot;ir&quot;, no %s
</pre>
<p>After some research turned out that <strong>RubyGems</strong> assumes that <strong>Ruby</strong> executable contains <em>&#8220;ruby&#8221;</em> word in the name. In case of <strong>IronRuby</strong> the name is <em>&#8220;ir.exe&#8221;</em> so in my opinion this strange behavior can be treated as a bug in <strong>RubyGems</strong>. I hope it will be fixed in next release but before that will happen here are the steps to workaround the problem and update <strong>gems</strong>:</p>
<p>1. Create path:<em> <strong>[IronRuby folder]\Lib\ruby\1.8\rubygems\defaults</strong></em><br />
2. Create file <strong><em>ironruby.rb</em></strong> and add it to the path from step 1<br />
3. Open <strong><em>ironruby.rb</em></strong> and add code from the snippet below</p>
<pre class="brush: ruby; title: ; notranslate">
module Gem
  def self.default_exec_format
    exec_format = ConfigMap[:ruby_install_name].sub('ruby', '%s') rescue '%s'
    #unless exec_format =~ /%s/ then
    #  raise Gem::Exception,
    #    &quot;[BUG] invalid exec_format #{exec_format.inspect}, no %s&quot;
    #end
    exec_format
  end
end
</pre>
<p>That is it. Now RubyGems will use new implementation of default_exec_format and everything should work as expected.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/bug-invalid-exec_format-ir/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ruby for Windows with debug support</title>
		<link>http://marcinobel.com/index.php/ruby-windows-debug-support/</link>
		<comments>http://marcinobel.com/index.php/ruby-windows-debug-support/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 13:56:36 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=283</guid>
		<description><![CDATA[I mentioned somewhere in previous posts I am playing a little with Ruby and Ruby on Rails. Because I do not have an experience yet, there are a lot of situations where I need a debugger to figure out how something works. Unfortunately before I was able to debug anything I spend a lot of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-16 alignleft" title="Ruby Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/ruby_logo.png" alt="" width="106" height="109" />I mentioned somewhere in previous posts I am playing a little with <a href="http://www.ruby-lang.org/en/" target="_blank"><strong>Ruby</strong></a> and <strong><a href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a></strong>. Because I do not have an experience yet, there are a lot of situations where I need a debugger to figure out how something works. Unfortunately before I was able to debug anything I spend a lot of time trying to enable debugging in <a href="http://www.jetbrains.com/ruby/" target="_blank"><strong>RubyMine</strong></a>. The main problem was in Ruby gems responsible for debugging. This gems are native C libraries and have to be compiled before usage. Of course you can guess that compilation did not work as expected. After long fight and few hours with Google I have managed to prepare a version of Ruby which can be used with RubyMine to debug applications.</p>
<p>Because Ruby for Windows does not require any installation I am able to easily provide you the version I have build mostly in order to save your time and do not describe whole procedure I had to follow during compilation.</p>
<p>The package contains <strong>Ruby 1.8.7 for Windows </strong>with following gems:</p>
<ul>
<li>actionmailer (2.3.5)</li>
<li>actionpack (2.3.5)</li>
<li>activerecord (2.3.5)</li>
<li>activeresource (2.3.5)</li>
<li>activesupport (2.3.5)</li>
<li>albacore (0.1.1, 0.1.0)</li>
<li>columnize (0.3.1)</li>
<li>linecache (0.43)</li>
<li>net-sftp (2.0.4)</li>
<li>net-ssh (2.0.19)</li>
<li>rack (1.1.0, 1.0.1)</li>
<li>rails (2.3.5)</li>
<li>rake (0.8.7)</li>
<li>RedCloth (4.2.2)</li>
<li><strong>ruby-debug</strong> (0.10.3)</li>
<li><strong>ruby-debug-base</strong> (0.10.3)</li>
<li><strong>ruby-debug-ide</strong> (0.4.9)</li>
<li>rubyzip (0.9.4, 0.9.1)</li>
<li>sqlite3-ruby (1.2.5)</li>
</ul>
<p>Installation is very simple. Uncompress files to <em>C:\Ruby</em> directory and add <em>C:\Ruby\bin</em> path to <em>PATH</em> environment variable.</p>
<h2><a href="http://marcinobel.com/download/Ruby.1.8.7.zip">Download Ruby 1.8.7 for Windows with debug support</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/ruby-windows-debug-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IronRuby/RHTML based templates for .NET</title>
		<link>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/</link>
		<comments>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 23:09:20 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=225</guid>
		<description><![CDATA[During last few days I was prototyping some of new features I would like to add to ByteCarrot application. One of them is new template engine which will replace current XSLT based solution. I wanted something with more friendly syntax, something easy to create, change and maintain. I took a look at many template engines [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png"><img class="alignleft size-full wp-image-21" title=".NET Logo" src="http://marcinobel.com/wp-content/uploads/2009/08/net_logo.png" alt=".NET Logo" width="240" height="74" /></a></p>
<p>During last few days I was prototyping some of new features I would like to add to <a title="ByteCarrot Project" href="http://bytecarrot.com" target="_blank"><strong>ByteCarrot </strong></a>application. One of them is new template engine which will replace current XSLT based solution. I wanted something with more friendly syntax, something easy to create, change and maintain. I took a look at many template engines available for .NET platform but none of them met my needs. I thought that it would be nice to have solution with scripting support and syntax similar to this available in default <strong><a title="ASP.NET MVC" href="http://www.asp.net/mvc/" target="_blank">ASP.NET MVC</a></strong> view engine.</p>
<p>After digging I have found an <strong>ASP.NET MVC</strong> application prototype with view engine based on <strong><a title="IronRuby" href="http://ironruby.net/" target="_blank">IronRuby</a></strong>. It was created by <strong><a title="Phil Haack" href="http://haacked.com/" target="_blank">Phil Haack</a></strong>&#8216;s team and its syntax was exactly the same as <strong>RHTML </strong>used in <strong><a title="Ruby on Rails" href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a></strong> views. It turned out that this engine was exactly what I needed, so I have taken parts of the code and adapted it to my scenario. The result is amazing because now I have fully functional templates engine with support of dynamic language where I can handle every possible HTML generation scenario.</p>
<p>As an attachment to this post I have added the code created during prototyping. The code contains few classes where the most important is <em>RhtmlEngine</em>. It has very simple, self-expanatory interface and acts as an &#8220;entry point&#8221; for using mentioned templates engine. Below you can find two samples showing capabilities of my solution but if you want to take a look at the implementation and make your hands dirty feel free to download the code and play with it for yourself.</p>
<pre class="brush: csharp; title: ; notranslate">
public class RhtmlEngine
{
    public Result Render(object model, string temlateFile, string targetFile)
        ...
    public Result Render(object model, StreamReader rhtml, StreamWriter writer)
        ...
}
</pre>
<h2>Simple template</h2>
<p>The templates engine requires three things to be able to generate HTML:</p>
<ul>
<li><strong>Model</strong> representing the data which should be presented in form of HTML page,</li>
<li><strong>Template</strong> defining how model should be presented,</li>
<li><strong>Target</strong> where generated HTML page should be saved.</li>
</ul>
<p>Listing below shows simple template generating a header and a list of hobbies. Notice that IronRuby blocks are embedded exactly the same as Visual Basic .NET or C# code is embedded in ASP.NET MVC views.</p>
<p><strong>SimpleTemplate.rhtml</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: &lt;%= model.FirstName %&gt;&lt;%= model.LastName %&gt;&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;% model.Hobbies.each do |hobby| %&gt;
			&lt;li&gt;&lt;%= hobby %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Template shown above can be used to generate an HTML representation of the following model:</p>
<pre class="brush: csharp; title: ; notranslate">
var model = new SampleModel
{
    FirstName = &quot;Marcin&quot;,
    LastName = &quot;Obel&quot;,
    Hobbies = new List&lt;string&gt;
    {
        &quot;yachting&quot;,
        &quot;fishing&quot;,
        &quot;cycling&quot;
    }
};
</pre>
<p>As you can notice looking at listing below, because the templates engine is very simple, you need only one line to change the model into HTML page.</p>
<pre class="brush: csharp; title: ; notranslate">
var result = new RhtmlEngine().Render(model, &quot;SimpleTemplate.rhtml&quot;, &quot;SimpleHtml.html&quot;);
</pre>
<p>In result (as shown below) the code above will produce clean HTML filled in with the data from model.</p>
<p><strong>SimpleHtml.html</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: MarcinObel&lt;/h2&gt;
        I like:
        &lt;ul&gt;
            &lt;li&gt;yachting&lt;/li&gt;
            &lt;li&gt;fishing&lt;/li&gt;
            &lt;li&gt;cycling&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>More advanced example</h2>
<p>The example above does not show the most powerful part of this solution which is in fact inherited from <strong>IronRuby </strong>itself. Because templates are based on fully functional, dynamic language there is a possibility to extend basic features like <em>loops</em> and <em>if</em> statements (available in all templates engines) with things like functions, classes or even use some functionalities available in .NET Framework. Next example extends this one mentioned in previous section. In the listing below you can notice two new functions:</p>
<ul>
<li><strong>encode </strong>- uses <em>HttpUtility </em>class from .NET Framework to encode HTML code</li>
<li><strong>render_li</strong> &#8211; renders an item of HTML list</li>
</ul>
<p><strong>AdvancedTemplate.rhtml</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;%
require 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
include System::Web

def encode(text)
    HttpUtility.HtmlEncode(text)
end

def render_li(text)
    writer.Write &quot;&lt;li&gt;#{text}&lt;/li&gt;&quot;;
end
%&gt;

&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: &lt;%= model.FirstName %&gt;&lt;%= model.LastName %&gt;&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;% model.Hobbies.each do |hobby|
                 render_li hobby
             end %&gt;
        &lt;/ul&gt;
        &lt;pre&gt;
            &lt;%= encode model.UglyJavaScript %&gt;
        &lt;/pre&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>In order to present a usage of custom <strong>IronRuby </strong>function added to the template, below you can find extended model from previous example. Now the model contains additional property named <em>UglyJavaScript </em>containing JavaScript code which should be encoded before it can be presented in HTML.</p>
<pre class="brush: csharp; title: ; notranslate">
var model = new SampleModel
{
    FirstName = &quot;Marcin&quot;,
    LastName = &quot;Obel&quot;,
    Hobbies = new List&lt;string&gt;
    {
        &quot;yachting&quot;,
        &quot;fishing&quot;,
        &quot;cycling&quot;
    },
    UglyJavaScript = @&quot;&lt;script type='text/javascript'&gt;window.close();&lt;/script&gt;&quot;
};

var result = new RhtmlEngine().Render(model, &quot;AdvancedTemplate.rhtml&quot;, &quot;AdvancedHtml.html&quot;);
</pre>
<p>Like in previous example after passing the model and the template into engine we receive an HTML.  This time as you can see it contains JavaScript code from model encoded using .NET Framework functionality in order to be able to display it.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;html&gt;
    &lt;body&gt;
        &lt;h1&gt;Hi! My name is: MarcinObel&lt;/h2&gt;
        I like:
        &lt;ul&gt;
        &lt;li&gt;yachting&lt;/li&gt;&lt;li&gt;fishing&lt;/li&gt;&lt;li&gt;cycling&lt;/li&gt;
        &lt;/ul&gt;
        &lt;pre&gt;
        &amp;lt;script type='text/javascript'&amp;gt;window.close();&amp;lt;/script&amp;gt;
        &lt;/pre&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>Resources</h2>
<ul>
<li><a title="RHTML templates engine source code" href="http://marcinobel.com/wp-content/uploads/Rhtml.Sample.zip" target="_blank">RHTML templates engine source code</a></li>
<li><a title="IronRuby official website" href="http://ironruby.net/" target="_blank">IronRuby official website</a></li>
<li><a title="Phil Haack" href="http://haacked.com/" target="_blank">Phil Haack&#8217;s blog</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/ironruby-rhtml-based-templates-for-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fluent NHibernate conventions &#8211; examples</title>
		<link>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/</link>
		<comments>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 22:22:59 +0000</pubDate>
		<dc:creator>Marcin Obel</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://marcinobel.com/?p=195</guid>
		<description><![CDATA[Fluent NHibernate is my favorite extension for NHibernate. I am using it since early betas and I have to say that I love it. One of its underestimated features are conventions. I decided to extract some of them from one of my projects and provide real life examples how they can be used. My conventions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png"><img class="alignleft size-full wp-image-210" title="Fluent NHibernate" src="http://marcinobel.com/wp-content/uploads/fluent-nhibernate.png" alt="Fluent NHibernate" width="360" height="117" /></a><strong><a title="Fluent NHibernate" href="http://fluentnhibernate.org/" target="_blank">Fluent NHibernate</a></strong> is my favorite extension for <strong><a title="NHibernate" href="http://nhforge.org/" target="_blank">NHibernate</a></strong>. I am using it since early betas and I have to say that I love it. One of its underestimated features are conventions. I decided to extract some of them from one of my projects and provide real life examples how they can be used. My conventions are listed below but if you need more information visit <strong><a title="Fluent NHibernate Documentation" href="http://wiki.fluentnhibernate.org/Conventions" target="_blank">Fluent NHibernate Wiki</a><span style="font-weight: normal;"> where this feature is described in detail</span></strong>.</p>
<p><strong>ColumnNullabilityConvention</strong> &#8211; says that if nullability for column has not been specified explicitly, should be set to &#8220;NOT NULL&#8221;.</p>
<pre class="brush: csharp; title: ; notranslate">
public class ColumnNullabilityConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Nullable, Is.Not.Set);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Not.Nullable();
    }
}
</pre>
<p><strong>CreatedAtPropertyAccessConvention</strong> &#8211; says that every property named <span style="text-decoration: underline;">CreatedAt </span>should be accessed through camel case field hidden behind it.</p>
<pre class="brush: csharp; title: ; notranslate">
public class CreatedAtPropertyAccessConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Property.Name == &quot;CreatedAt&quot;);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Access.ReadOnlyPropertyThroughCamelCaseField(
            CamelCasePrefix.Underscore);
    }
}
</pre>
<p><strong>ForeignKeyConstraintNameConvention</strong> &#8211; says that name of every foreign key constraint representing one to many relation should consist of names of entities for which it was specified.</p>
<pre class="brush: csharp; title: ; notranslate">
public class ForeignKeyConstraintNameConvention
    : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Key.ForeignKey(&quot;{0}_{1}_FK&quot;.AsFormat(
        instance.Member.Name, instance.EntityType.Name));
    }
}
</pre>
<p><strong>ForeignKeyNameConvention</strong> &#8211; says that name of every column containing foreign key id should consist of name of type which it points to with &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp; title: ; notranslate">
public class ForeignKeyNameConvention : IHasManyConvention
{
    public void Apply(IOneToManyCollectionInstance instance)
    {
        instance.Key.Column(instance.EntityType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>PrimaryKeyNameConvention </strong>- says that name of every column representing primary key should consist of entity name and &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp; title: ; notranslate">
public class PrimaryKeyNameConvention : IIdConvention
{
    public void Apply(IIdentityInstance instance)
    {
        instance.Column(instance.EntityType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>ReferenceConvention</strong> &#8211; says that name of column referenced in many to one convention should consist of entity name and &#8220;Id&#8221; suffix.</p>
<pre class="brush: csharp; title: ; notranslate">
public class ReferenceConvention : IReferenceConvention
{
    public void Apply(IManyToOneInstance instance)
    {
        instance.Column(instance.Property.PropertyType.Name + &quot;Id&quot;);
    }
}
</pre>
<p><strong>StringColumnLengthConvention</strong> &#8211; says that if length for string column has not been specified, it should be set to 100.</p>
<pre class="brush: csharp; title: ; notranslate">
public class StringColumnLengthConvention
    : IPropertyConvention, IPropertyConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IPropertyInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.Type == typeof(string))
            .Expect(x =&gt; x.Length == 0);
    }

    public void Apply(IPropertyInstance instance)
    {
        instance.Length(100);
    }
}
</pre>
<p><strong>TableNameConvention</strong> &#8211; says that if name for table has not been specified, it should be created using concatenation of entity name and &#8220;s&#8221; suffix.</p>
<pre class="brush: csharp; title: ; notranslate">
public class TableNameConvention
    : IClassConvention, IClassConventionAcceptance
{
    public void Accept(IAcceptanceCriteria&lt;IClassInspector&gt; criteria)
    {
        criteria.Expect(x =&gt; x.TableName, Is.Not.Set);
    }

    public void Apply(IClassInstance instance)
    {
        instance.Table(instance.EntityType.Name + &quot;s&quot;);
    }
}
</pre>
<p><strong>At the end the most important thing</strong> which shows that such conventions make sense. With default <strong>Fluent NHibernate</strong> conventions DDL generated by NHibernate for MySQL looked like this:</p>
<pre class="brush: sql; title: ; notranslate">
alter table `Athlete`  drop foreign key FK9221C9B94070A6F0

drop table if exists Countries

drop table if exists `Athlete`

create table Countries (
     Id INTEGER NOT NULL AUTO_INCREMENT,
     Name VARCHAR(255),
     primary key (Id)
)

create table `Athlete` (
     Id INTEGER NOT NULL AUTO_INCREMENT,
     DisplayName VARCHAR(255),
     Email VARCHAR(255),
     Password VARCHAR(255),
     CreatedAt DATETIME,
     IsActive TINYINT(1),
     Country_id INTEGER,
     primary key (Id)
)

alter table `Athlete`
	add index (Country_id),
	add constraint FK9221C9B94070A6F0
	foreign key (Country_id)
	references Countries (Id)
</pre>
<p>When I have applied conventions mentioned above to my fluent mappings DDL looks like this:</p>
<pre class="brush: sql; title: ; notranslate">
alter table Athletes  drop foreign key Athletes_Country_FK

drop table if exists Athletes

drop table if exists Countries

create table Athletes (
     AthleteId INTEGER NOT NULL AUTO_INCREMENT,
     DisplayName VARCHAR(100) not null,
     Email VARCHAR(100) not null,
     Password VARCHAR(100) not null,
     CreatedAt DATETIME not null,
     IsActive TINYINT(1) not null,
     CountryId INTEGER,
     primary key (AthleteId)
)

create table Countries (
     CountryId INTEGER NOT NULL AUTO_INCREMENT,
     Name VARCHAR(100) not null,
     primary key (CountryId)
)

alter table Athletes
	add index (CountryId),
	add constraint Athletes_Country_FK
	foreign key (CountryId)
	references Countries (CountryId)
</pre>
<p>For me it looks much better. Additionally I have made it once and that is it. Now I have to care only about domain model and business logic without thinking about not so important stuff lake names of database objects.</p>
]]></content:encoded>
			<wfw:commentRss>http://marcinobel.com/index.php/fluent-nhibernate-conventions-examples/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

