<?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>Alonso Robles &#187; .NET Development</title>
	<atom:link href="http://alonsorobles.com/category/dotnet-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://alonsorobles.com</link>
	<description>technology, academia, and other tidbits from the trenches of a boggled mind</description>
	<lastBuildDate>Wed, 18 Apr 2012 02:48:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>RavenDB Document Identifiers and MVC Routes</title>
		<link>http://alonsorobles.com/2012/03/21/ravendb-document-identifiers-and-mvc-routes/</link>
		<comments>http://alonsorobles.com/2012/03/21/ravendb-document-identifiers-and-mvc-routes/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 11:38:39 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[RavenDB]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[MVC 3]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=353</guid>
		<description><![CDATA[Following my recent post about getting started with RavenDB, I decided to work on a small shopping cart demo application based on the sample depot application that is written in part 2 of Agile Web Development with Rails when I &#8230; <a href="http://alonsorobles.com/2012/03/21/ravendb-document-identifiers-and-mvc-routes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following my recent post about <a href="http://www.headspring.com/2012/03/getting-started-with-ravendb">getting started with RavenDB</a>, I decided to work on a small shopping cart demo application based on the sample depot application that is written in part 2 of <a href="http://www.amazon.com/gp/product/1934356549/ref=as_li_ss_tl?ie=UTF8&amp;tag=importchaos-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1934356549">Agile Web Development with Rails </a><img style="margin: 0px; border-style: none !important;" src="http://www.assoc-amazon.com/e/ir?t=importchaos-20&amp;l=as2&amp;o=1&amp;a=1934356549" alt="" width="1" height="1" border="0" /> when I started running into some trouble with the RavenDB auto generated document identifiers and the MVC routes. Like any other programmer, I quickly performed a Google search to see what others had done. The search led me to a few Stack Overflow well voted answers all leading me to <a href="http://weblogs.asp.net/shijuvarghese/archive/2010/06/04/how-to-work-ravendb-id-with-asp-net-mvc-routes.aspx">a blog post on this topic</a>. Problem solved right? Not exactly. Two solutions were proposed. But before getting into those, I want to describe the problem a little more.</p>
<h3>The Problem Described</h3>
<p>Take a look at the ASP.NET MVC 3 default route found in the <em>Global.asax.cs</em> file: <div id="gist-2136967" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">public</span> <span class="k">static</span> <span class="k">void</span> <span class="nf">RegisterRoutes</span><span class="p">(</span><span class="n">RouteCollection</span> <span class="n">routes</span><span class="p">)</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">routes</span><span class="p">.</span><span class="n">IgnoreRoute</span><span class="p">(</span><span class="s">&quot;{resource}.axd/{*pathInfo}&quot;</span><span class="p">);</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">routes</span><span class="p">.</span><span class="n">MapRoute</span><span class="p">(</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s">&quot;Default&quot;</span><span class="p">,</span> <span class="c1">// Route name</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s">&quot;{controller}/{action}/{id}&quot;</span><span class="p">,</span> <span class="c1">// URL with parameters</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">new</span> <span class="p">{</span> <span class="n">controller</span> <span class="p">=</span> <span class="s">&quot;Home&quot;</span><span class="p">,</span> <span class="n">action</span> <span class="p">=</span> <span class="s">&quot;Index&quot;</span><span class="p">,</span> <span class="n">id</span> <span class="p">=</span> <span class="n">UrlParameter</span><span class="p">.</span><span class="n">Optional</span> <span class="p">}</span> <span class="c1">// Parameter defaults</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">);</span></div><div class='line' id='LC10'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2136967/c084f7d16a710152ca01c1d4d6f643a98f703ea3/gistfile1.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2136967#file_gistfile1.cs" style="float:right;margin-right:10px;color:#666">gistfile1.cs</a>
            <a href="https://gist.github.com/2136967">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<p>This default route will basically allow you access to a resource using the basic URL convention that may look something this: <em>http://localhost/products/edit/1</em> . However, the default RavenDB auto generated document identifier for the product document ends up looking something like this: p<em>roducts/1</em>. (More information about the RavenDB <a href="http://ravendb.net/docs/client-api/basic-operations/saving-new-document">document identifiers one of the documentation pages</a>. ) So the URL to access that product resource for editing would really have to look like this: <em>http://localhost/products/edit/products/1</em>. Well that doesn’t work for two reasons:</p>
<ol>
<li>The default route will not be matched so the URL will not be routed the correct controller action.</li>
<li>The URL is not SEO friendly.</li>
</ol>
<p>Typically, this can be solved by using a custom route that access this resource by a natural key where the URL would probably end up looking like this: <em>http://localhost/products/product-name/edit</em>. This makes the URL SEO friendly, easy to read, and easy to route. However, there are some situations where the document identifier makes sense and I will continue this post on the assumption that this is the case.</p>
<p>The blog post mentioned above presents two solutions:</p>
<ul>
<li>Solution 1 – Change the identity parts separator convention for the RavenDB document store.</li>
<li>Solution 2 – Modify the ASP.NET default route</li>
</ul>
<h3>Issues with Solution 1</h3>
<p>Let’s look at the first solution. The suggestion is to change the identity separator convention from a slash (/) to a dash (-). The convention is really easy to change during the initialization of the document store object.</p>
<div id="gist-2137105" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="n">documentStore</span> <span class="p">=</span> <span class="k">new</span> <span class="n">DocumentStore</span> <span class="p">{</span> <span class="n">Url</span> <span class="p">=</span> <span class="s">&quot;http://localhost:8080/&quot;</span> <span class="p">};</span></div><div class='line' id='LC2'><span class="n">documentStore</span><span class="p">.</span><span class="n">Initialize</span><span class="p">();</span></div><div class='line' id='LC3'><span class="n">documentStore</span><span class="p">.</span><span class="n">Conventions</span><span class="p">.</span><span class="n">IdentityPartsSeparator</span> <span class="p">=</span> <span class="s">&quot;-&quot;</span><span class="p">;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2137105/c7f32ad41de8d44b30c10c8138edcb12215b3ad9/gistfile1.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2137105#file_gistfile1.cs" style="float:right;margin-right:10px;color:#666">gistfile1.cs</a>
            <a href="https://gist.github.com/2137105">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>This makes RavenDB generate document identifiers that now look like: <em>products-1</em>. Now we can generate a URL that will match the default route and may look like: <em>http://localhost/products/edit/products-1</em>. I still find some issues this this. Namely, the URL is still not really SEO friendly and not really human readable. I don’t like the idea of exposing an identifier that was forced on me by RavenDB since it essentially has coupled my URL to the RavenDB identifier convention. It just doesn’t feel right.</p>
<h3>Issues with Solution 2</h3>
<p>This solution suggests the change of the default route to something like:</p>
<div id="gist-2137442" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">public</span> <span class="k">static</span> <span class="k">void</span> <span class="nf">RegisterRoutes</span><span class="p">(</span><span class="n">RouteCollection</span> <span class="n">routes</span><span class="p">)</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">routes</span><span class="p">.</span><span class="n">IgnoreRoute</span><span class="p">(</span><span class="s">&quot;{resource}.axd/{*pathInfo}&quot;</span><span class="p">);</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">routes</span><span class="p">.</span><span class="n">MapRoute</span><span class="p">(</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s">&quot;Default&quot;</span><span class="p">,</span> <span class="c1">// Route name</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="s">&quot;{controller}/{action}/{*id}&quot;</span><span class="p">,</span> <span class="c1">// URL with parameters</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">new</span> <span class="p">{</span> <span class="n">controller</span> <span class="p">=</span> <span class="s">&quot;Home&quot;</span><span class="p">,</span> <span class="n">action</span> <span class="p">=</span> <span class="s">&quot;Index&quot;</span><span class="p">,</span> <span class="n">id</span> <span class="p">=</span> <span class="n">UrlParameter</span><span class="p">.</span><span class="n">Optional</span> <span class="p">}</span> <span class="c1">// Parameter defaults</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">);</span></div><div class='line' id='LC10'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2137442/d2469600b573423dec4dbb7fd4e1153ac431fd34/gistfile1.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2137442#file_gistfile1.cs" style="float:right;margin-right:10px;color:#666">gistfile1.cs</a>
            <a href="https://gist.github.com/2137442">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>This will allow route to match a URL that looked like the first one: <em>http://localhost/products/edit/products/1</em>. I don’t like this either. While it does allow the default route to match and do its job. The URL is just ugly. It also clobbers the id making the route also match something like this: <em>http://localhost/products/edit/products/more-junk/1</em>. Obviously this is not SEO friendly or human readable. Again, it just doesn’t feel right.</p>
<h3>Another Option</h3>
<p>After some digging and learning about more about the document identity field, identity type converters, custom identifiers with the document key generator convention, I realized there was a pretty simple alternative to the two options above. But to see it and to understand the simplicity, you have to look at the source of the problem.</p>
<p>The reason that MVC routes are choking on the preconfigured RavenDB document identity convention is because our models included a string based identity property. I realized I had done this on purpose to ease the mapping of the RavenDB document identifier and my object identifier. Take a look at my product object definition:</p>
<div id="gist-2205818" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">public</span> <span class="k">class</span> <span class="nc">Product</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">Id</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">Title</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">Description</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">ImageUrl</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">decimal</span> <span class="n">Price</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC8'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2205818/f76935b0b33b0148ca2a67b57078be7a859b3c4f/Product.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2205818#file_product.cs" style="float:right;margin-right:10px;color:#666">Product.cs</a>
            <a href="https://gist.github.com/2205818">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>The shopping cart identifier is a string. Why would it be a string? It could have been an integer or a Guid or something else. It could have even been a natural key of some sort. Or even a compound key. It doesn’t have to be a string. Taking another look at the  IDocumentSession interface we can see we have four load methods available.</p>
<div id="gist-2153059" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">namespace</span> <span class="nn">Raven.Client</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="k">public</span> <span class="k">interface</span> <span class="n">IDocumentSession</span> <span class="p">:</span> <span class="n">IDisposable</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ISyncAdvancedSessionOperation</span> <span class="n">Advanced</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="n">Delete</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="n">T</span> <span class="n">entity</span><span class="p">);</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">T</span> <span class="n">Load</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="kt">string</span> <span class="n">id</span><span class="p">);</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">T</span><span class="p">[]</span> <span class="n">Load</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="k">params</span> <span class="kt">string</span><span class="p">[]</span> <span class="n">ids</span><span class="p">);</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">T</span><span class="p">[]</span> <span class="n">Load</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="n">IEnumerable</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;</span> <span class="n">ids</span><span class="p">);</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">T</span> <span class="n">Load</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="n">ValueType</span> <span class="n">id</span><span class="p">);</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">IRavenQueryable</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;</span> <span class="n">Query</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="kt">string</span> <span class="n">indexName</span><span class="p">);</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">IRavenQueryable</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;</span> <span class="n">Query</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;();</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">IRavenQueryable</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;</span> <span class="n">Query</span><span class="p">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="n">TIndexCreator</span><span class="p">&gt;()</span> <span class="k">where</span> <span class="n">TIndexCreator</span> <span class="p">:</span> <span class="n">AbstractIndexCreationTask</span><span class="p">,</span> <span class="k">new</span><span class="p">();</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ILoaderWithInclude</span><span class="p">&lt;</span><span class="kt">object</span><span class="p">&gt;</span> <span class="n">Include</span><span class="p">(</span><span class="kt">string</span> <span class="n">path</span><span class="p">);</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">ILoaderWithInclude</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;</span> <span class="n">Include</span><span class="p">&lt;</span><span class="n">T</span><span class="p">&gt;(</span><span class="n">Expression</span><span class="p">&lt;</span><span class="n">Func</span><span class="p">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="kt">object</span><span class="p">&gt;&gt;</span> <span class="n">path</span><span class="p">);</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="nf">SaveChanges</span><span class="p">();</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="nf">Store</span><span class="p">(</span><span class="kt">object</span> <span class="n">entity</span><span class="p">,</span> <span class="n">Guid</span> <span class="n">etag</span><span class="p">);</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="nf">Store</span><span class="p">(</span><span class="kt">object</span> <span class="n">entity</span><span class="p">,</span> <span class="n">Guid</span> <span class="n">etag</span><span class="p">,</span> <span class="kt">string</span> <span class="n">id</span><span class="p">);</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="nf">Store</span><span class="p">(</span><span class="kt">object</span> <span class="n">entity</span><span class="p">);</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">void</span> <span class="nf">Store</span><span class="p">(</span><span class="kt">object</span> <span class="n">entity</span><span class="p">,</span> <span class="kt">string</span> <span class="n">id</span><span class="p">);</span></div><div class='line' id='LC21'>&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC22'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2153059/64fbb98ab03ac0e3fc1f07fb5f07d4851a1c7e5c/gistfile1.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2153059#file_gistfile1.cs" style="float:right;margin-right:10px;color:#666">gistfile1.cs</a>
            <a href="https://gist.github.com/2153059">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>After thinking about the difference between the method that accepts a string identifier and the one that accepts a value type identifier, I realized that all I had to do was change my identifier type from a string to a value type and I’m done. No fancy mapping or parsing the document identifier from RavenDB to the web browser and back. No changes to the default MVC route. No changes to the default identity separator convention. It just worked. My URLs are SEO friendly and more readable.</p>
<p>All I had to do was change the object identifier type.</p>
<div id="gist-2205829" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">public</span> <span class="k">class</span> <span class="nc">Product</span></div><div class='line' id='LC2'><span class="p">{</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">int</span> <span class="n">Id</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">Title</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">Description</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">string</span> <span class="n">ImageUrl</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">public</span> <span class="kt">decimal</span> <span class="n">Price</span> <span class="p">{</span> <span class="k">get</span><span class="p">;</span> <span class="k">set</span><span class="p">;</span> <span class="p">}</span></div><div class='line' id='LC8'><span class="p">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/2205829/dec0f6ca4b6fc6c058955333b789496725191f02/Product.cs" style="float:right;">view raw</a>
            <a href="https://gist.github.com/2205829#file_product.cs" style="float:right;margin-right:10px;color:#666">Product.cs</a>
            <a href="https://gist.github.com/2205829">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>That was easy.</p>
<p>Of course this doesn’t solve everything. What if I really do need a string based identifier? This will probably require tweaking the behavior of the RavenDB client. I also don’t have an answer for compound keys and other natural keys which may not be a value type. Some of these may require more thought from both the RavenDB side and the MVC side of my project. But that is another problem to think about some other time.</p>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2012/03/21/ravendb-document-identifiers-and-mvc-routes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two SharePoint 2010 Webinars for Developers</title>
		<link>http://alonsorobles.com/2011/01/26/two-sharepoint-2010-webinars-for-developers/</link>
		<comments>http://alonsorobles.com/2011/01/26/two-sharepoint-2010-webinars-for-developers/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 07:00:30 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[Microsoft Office]]></category>
		<category><![CDATA[Sharepoint Server]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Windows Sharepoint Services]]></category>
		<category><![CDATA[caml]]></category>
		<category><![CDATA[client object model]]></category>
		<category><![CDATA[data access]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[linq 2 sharepoint]]></category>
		<category><![CDATA[odata]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[sharepoint 2010]]></category>
		<category><![CDATA[SharePoint Server 2010]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=241</guid>
		<description><![CDATA[Andrew Connell, a SharePoint MVP, hosted two introduction to SharePoint 2010 webinars for developers over the last couple of days in conjuction with DevExpress. These were a really good concise introduction to SharePoint development. I would recommend that anyone who is &#8230; <a href="http://alonsorobles.com/2011/01/26/two-sharepoint-2010-webinars-for-developers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.andrewconnell.com/blog">Andrew Connell</a>, a SharePoint MVP, hosted two introduction to SharePoint 2010 webinars for developers over the last couple of days in conjuction with <a href="http://www.devexpress.com/">DevExpress</a>. These were a really good concise introduction to SharePoint development. I would recommend that anyone who is interested in getting started with SharePoint development take a couple of hours to check these out.</p>
<h3>Intoduction to SharePoint 2010 for Developers</h3>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube-nocookie.com/v/wOdvARkMzGo?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/wOdvARkMzGo?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>This webinar is also available on the <a href="http://tv.devexpress.com/#IntroToSharePointWebinar">DevExpress Channel</a>.</p>
<h3>SharePoint 2010 Data Access</h3>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube-nocookie.com/v/GwZQEu64Rlk?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/GwZQEu64Rlk?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>This webinar is also available on the <a href="http://tv.devexpress.com/#SharePoint2010DataAccessWebinar">DevExpress Channel</a>.</p>
<p>Andrew was also kind enough to publish <a href="http://www.andrewconnell.com/blog/archive/2011/01/26/wrap-up-from-my-devexpress-webinar-today.aspx">a wrap-up blog post</a> with links to additional references.</p>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2011/01/26/two-sharepoint-2010-webinars-for-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guerrilla Threat Modelling (or &#8216;Threat Modeling&#8217;)</title>
		<link>http://alonsorobles.com/2010/08/23/guerrilla-threat-modelling-or-threat-modeling/</link>
		<comments>http://alonsorobles.com/2010/08/23/guerrilla-threat-modelling-or-threat-modeling/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 20:16:36 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[threat modeling]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=193</guid>
		<description><![CDATA[An interesting read on Guerrilla Threat Modelling (or &#8216;Threat Modeling&#8217; if you&#8217;re American) by Peter Torr. This is a relatively old post, but still applies today. In addition, a good practice to implementing threat countermeasures is the STRIDE approach which is described &#8230; <a href="http://alonsorobles.com/2010/08/23/guerrilla-threat-modelling-or-threat-modeling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>An interesting read on <a href="http://blogs.msdn.com/b/ptorr/archive/2005/02/22/guerillathreatmodelling.aspx">Guerrilla Threat Modelling (or &#8216;Threat Modeling&#8217; if you&#8217;re American)</a> by Peter Torr. This is a relatively old post, but still applies today. In addition, a good practice to implementing threat countermeasures is the <a title="Uncover Security Design Flaws Using The STRIDE Approach" href="http://msdn.microsoft.com/en-us/magazine/cc163519.aspx">STRIDE approach which is described in MSDN magazine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2010/08/23/guerrilla-threat-modelling-or-threat-modeling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inversion of Control Frameworks</title>
		<link>http://alonsorobles.com/2010/08/23/inversion-of-control-frameworks/</link>
		<comments>http://alonsorobles.com/2010/08/23/inversion-of-control-frameworks/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 17:49:11 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[IoC]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=191</guid>
		<description><![CDATA[Here is a quick list of Inversion of Control Frameworks: MicroKernel/Windsor Castle Project Ninject Spring.NET Structure Map Unity]]></description>
			<content:encoded><![CDATA[<p>Here is a quick list of Inversion of Control Frameworks:</p>
<ul>
<li><a href="http://www.castleproject.org/container/">MicroKernel/Windsor Castle Project</a></li>
<li><a href="http://www.ninject.org/">Ninject</a></li>
<li><a href="http://www.springframework.net/">Spring.NET</a></li>
<li><a href="http://structuremap.sourceforge.net/">Structure Map</a></li>
<li><a href="http://unity.codeplex.com/">Unity</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2010/08/23/inversion-of-control-frameworks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development and Design Guidelines for .NET Framework 4</title>
		<link>http://alonsorobles.com/2010/08/23/development-and-design-guidelines-for-net-framework-4/</link>
		<comments>http://alonsorobles.com/2010/08/23/development-and-design-guidelines-for-net-framework-4/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 16:17:56 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[.NET Framework]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=188</guid>
		<description><![CDATA[Ran across Krzysztof Cwalina&#8217;s MSDN blog while reading Microsoft .NET: Architecting Applications for the Enterprise (PRO-Developer). Lot&#8217;s of good content here regarding development and design guidelines for using the .NET Framework. The official design guidelines for developing class libraries with &#8230; <a href="http://alonsorobles.com/2010/08/23/development-and-design-guidelines-for-net-framework-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ran across <a href="http://blogs.msdn.com/b/kcwalina/">Krzysztof Cwalina&#8217;s MSDN blog</a> while reading <a href="http://www.amazon.com/gp/product/073562609X?ie=UTF8&amp;tag=importchaos-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=073562609X">Microsoft .NET: Architecting Applications for the Enterprise (PRO-Developer)</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=importchaos-20&amp;l=as2&amp;o=1&amp;a=073562609X" border="0" alt="" width="1" height="1" />. Lot&#8217;s of good content here regarding development and design guidelines for using the .NET Framework. The <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx">official design guidelines for developing class libraries with the .NET Framework 4</a> can be found on MSDN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2010/08/23/development-and-design-guidelines-for-net-framework-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List of SharePoint 2007 Web Templates</title>
		<link>http://alonsorobles.com/2010/05/17/list-of-sharepoint-2007-web-templates/</link>
		<comments>http://alonsorobles.com/2010/05/17/list-of-sharepoint-2007-web-templates/#comments</comments>
		<pubDate>Mon, 17 May 2010 21:51:06 +0000</pubDate>
		<dc:creator>Alonso Robles</dc:creator>
				<category><![CDATA[.NET Development]]></category>
		<category><![CDATA[Microsoft Office]]></category>
		<category><![CDATA[Sharepoint Server]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Windows Sharepoint Services]]></category>
		<category><![CDATA[moss 2007]]></category>
		<category><![CDATA[wss 3.0]]></category>

		<guid isPermaLink="false">http://alonsorobles.com/?p=172</guid>
		<description><![CDATA[I came across this reference in the past and I needed it again today. Took me a few minutes to find it, so I decided to save a copy of the table here on my blog: Template Name Description GLOBAL#0 &#8230; <a href="http://alonsorobles.com/2010/05/17/list-of-sharepoint-2007-web-templates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I came across <a title="Sharepoint Templates - Types " href="http://blogs.technet.com/araviraj/archive/2008/06/18/sharepoint-templates-types.aspx">this reference</a> in the past and I needed it again today. Took me a few minutes to find it, so I decided to save a copy of the table here on my blog:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="319" valign="top">Template Name</td>
<td width="319" valign="top">Description</td>
</tr>
<tr>
<td width="319" valign="top">GLOBAL#0</td>
<td width="319" valign="top"> Global template (1033)</td>
</tr>
<tr>
<td width="319" valign="top">STS#0</td>
<td width="319" valign="top"> Team Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">STS#1</td>
<td width="319" valign="top"> Blank Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">STS#2</td>
<td width="319" valign="top"> Document Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">MPS#0</td>
<td width="319" valign="top"> Basic Meeting Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">MPS#1</td>
<td width="319" valign="top"> Blank Meeting Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">MPS#2</td>
<td width="319" valign="top"> Decision Meeting Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">MPS#3</td>
<td width="319" valign="top"> Social Meeting Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">MPS#4</td>
<td width="319" valign="top"> Multipage Meeting Workspace (1033)</td>
</tr>
<tr>
<td width="319" valign="top">CENTRALADMIN#0</td>
<td width="319" valign="top"> Central Admin Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">WIKI#0</td>
<td width="319" valign="top"> Wiki Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BLOG#0</td>
<td width="319" valign="top"> Blog (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BDR#0</td>
<td width="319" valign="top"> Document Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">OFFILE#0</td>
<td width="319" valign="top"> Records Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">OFFILE#1</td>
<td width="319" valign="top"> Records Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">OSRV#0</td>
<td width="319" valign="top"> Shared Services Administration Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPS#0</td>
<td width="319" valign="top"> SharePoint Portal Server Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSPERS#0</td>
<td width="319" valign="top"> SharePoint Portal Server Personal Space (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSMSITE#0</td>
<td width="319" valign="top"> Personalization Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSTOC#0</td>
<td width="319" valign="top"> Contents area Template (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSTOPIC#0</td>
<td width="319" valign="top"> Topic area template (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSNEWS#0</td>
<td width="319" valign="top"> News Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">CMSPUBLISHING#0</td>
<td width="319" valign="top"> Publishing Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BLANKINTERNET#0</td>
<td width="319" valign="top"> Publishing Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BLANKINTERNET#1</td>
<td width="319" valign="top"> Press Releases Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BLANKINTERNET#2</td>
<td width="319" valign="top"> Publishing Site with Workflow (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSNHOME#0</td>
<td width="319" valign="top"> News Site (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSSITES#0</td>
<td width="319" valign="top"> Site Directory (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSCOMMU#0</td>
<td width="319" valign="top"> Community area template (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSREPORTCENTER#0</td>
<td width="319" valign="top"> Report Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSPORTAL#0</td>
<td width="319" valign="top"> Collaboration Portal (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SRCHCEN#0</td>
<td width="319" valign="top"> Search Center with Tabs (1033)</td>
</tr>
<tr>
<td width="319" valign="top">PROFILES#0</td>
<td width="319" valign="top"> Profiles (1033)</td>
</tr>
<tr>
<td width="319" valign="top">BLANKINTERNETCONTAINER#0</td>
<td width="319" valign="top"> Publishing Portal (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSMSITEHOST#0</td>
<td width="319" valign="top"> My Site Host (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SRCHCENTERLITE#0</td>
<td width="319" valign="top"> Search Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SRCHCENTERLITE#1</td>
<td width="319" valign="top"> Search Center (1033)</td>
</tr>
<tr>
<td width="319" valign="top">SPSBWEB#0</td>
<td width="319" valign="top"> SharePoint Portal Server BucketWeb Template (1033)</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://alonsorobles.com/2010/05/17/list-of-sharepoint-2007-web-templates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

