<?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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Daniel Lang</title>
	
	<link>http://daniellang.net</link>
	<description>programming, ravendb, tech things</description>
	<lastBuildDate>Fri, 26 Apr 2013 10:15:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/daniellangnet" /><feedburner:info uri="daniellangnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>daniellangnet</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Joining documents in RavenDB 2.0</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/NMNSkYdVTE0/</link>
		<comments>http://daniellang.net/joining-documents-in-ravendb-2-0/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 03:15:43 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=711</guid>
		<description><![CDATA[<p>One of the main differences between relational databases and document databases is the lack of native joining capabilities, right? This is no longer true for RavenDB. Yes, we already had very effective ways to deal with document relations before, but now in RavenDB 2.0 we can do much better. Let’s say our model looks like [...]</p><p>The post <a href="http://daniellang.net/joining-documents-in-ravendb-2-0/">Joining documents in RavenDB 2.0</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>One of the main differences between relational databases and document databases is the lack of native joining capabilities, right? This is no longer true for RavenDB. Yes, we already had very effective ways to <a href="http://daniellang.net/how-to-handle-relations-in-ravendb/">deal with document relations</a> before, but now in RavenDB 2.0 we can do much better.</p>
<p>Let’s say our model looks like this:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" alt="image" src="http://daniellang.net/wp-content/uploads/2013/01/image.png" width="291" height="217" border="0" /></p>
<p>In order to display a list of posts, we need the title, the author’s name and the content. So we effectively need to join posts with their authors. This is what we want:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" alt="image" src="http://daniellang.net/wp-content/uploads/2013/01/image1.png" width="313" height="120" border="0" /></p>
<p>If you don’t know how to do this in RavenDB 1.0, please go to <a href="http://daniellang.net/how-to-handle-relations-in-ravendb/">this post</a>.</p>
<p>In RavenDB 2.0 however, there is a new feature that let’s us <a href="http://ayende.com/blog/160513/ravendb-feature-of-the-year-indexing-related-documents">load documents during indexing time</a>. This means, we can load the related author document while we index the post document. Combine this features with the <a href="http://daniellang.net/using-an-index-as-a-materialized-view-in-ravendb/">possibility to use an index as the read-store</a> for your queries…</p>
<p>Here’s how our index looks like:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" alt="image" src="http://daniellang.net/wp-content/uploads/2013/01/image2.png" width="573" height="297" border="0" /></p>
<p>Note how we first load the author document and then store the author’s name inside our index, so we can get that value back at query time.</p>
<p>Here’s how a query looks like:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" alt="image" src="http://daniellang.net/wp-content/uploads/2013/01/image3.png" width="341" height="52" border="0" /></p>
<p>How awesome is that?</p>
<p>Please note that RavenDB does not load the author document at query time. Instead, it already has the author’s name stored in the index, so querying is as ultra-fast as if there wasn’t any relation at all.</p>
<p>If the author&#8217;s name changes, RavenDB will automatically recompute the index for all the posts that are related with that author. <strong>Unlike with denormalized references, we don’t need to maintain that relation!</strong></p>
<p>Personally, I think this will fundamentally change how we work with RavenDB. Do you agree?</p>
<p>The post <a href="http://daniellang.net/joining-documents-in-ravendb-2-0/">Joining documents in RavenDB 2.0</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/joining-documents-in-ravendb-2-0/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://daniellang.net/joining-documents-in-ravendb-2-0/</feedburner:origLink></item>
		<item>
		<title>Please stop using email signatures</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/NL5wsLFscw0/</link>
		<comments>http://daniellang.net/please-stop-using-email-signatures/#comments</comments>
		<pubDate>Wed, 02 Jan 2013 22:43:37 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=702</guid>
		<description><![CDATA[<p>Every morning I need to dig through a pile of emails waiting in my inbox. I hate that. I really, really hate to do emailing. I am a developer first and foremost and I personally feel guilty every minute I don’t spend writing actual code or doing something productive. Doing email is definitively not one [...]</p><p>The post <a href="http://daniellang.net/please-stop-using-email-signatures/">Please stop using email signatures</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Every morning I need to dig through a pile of emails waiting in my inbox. I hate that. I really, really hate to do emailing. I am a developer first and foremost and I personally feel guilty every minute I don’t spend writing actual code or doing something <em>productive</em>.</p>
<p>Doing email is definitively not one of the things I consider to be productive work. Think about it: when was the last time you felt like you did get a lot of things done after spending a couple of hours in Gmail? You get it, never!</p>
<p>This is why I personally try to spend as little time as possible in my email client, which is Outlook by the way. I know every keyboard shortcut by heart and I can literally fly through my inbox, replying, deleting and marking items with only a few keystrokes. However, there’s one type of emails that makes me want to cry. They basically go along like this:</p>
<blockquote><p>From: Somebody (<a href="mailto:somebody@contoso.tld">somebody@contoso.tld</a>)<br />
Subject: RE: Meeting tomorrow?</p>
<p>Hello Daniel,</p>
<p>Hope you’re doing good.</p>
<p>In regards to your proposed meeting tomorrow, yes, 4pm is just fine.</p>
<p>Have a nice afternoon,</p>
<p>Somebody</p>
<p>Chief Executive Sucker</p>
<p>Something Corporation<br />
<em>Checkout our new Facebook site at…<br />
</em></p>
<p>Phone: +33 44 55 66 77<br />
Fax: +77 88 99 11 22</p>
<p>Email: <a href="mailto:somebody@contoso.tld">somebody@contoso.tld</a><br />
Web: <a href="http://www.contoso.tld">www.contoso.tld</a></p>
<p>Confidentiality Warning: This e-mail contains information intended only for the use of the individual or entity named above. If the reader of this e-mail is not the intended recipient or the employee or agent responsible for delivering it to the intended recipient, any dissemination, publication or copying of this e-mail is strictly prohibited. The sender does not accept any responsibility for any loss, disruption or damage to your data or computer system that may occur while using data contained in, or transmitted with, this e-mail. If you have received this e-mail in error, please immediately notify us by return e-mail. Thank you.</p></blockquote>
<p>Seriously? Why are you doing this to me? Only 5 minutes ago I sent you an email asking if 4pm tomorrow was a good time to do the monthly project meeting. Because you are replying to my email, there’s no need to establish context first. I know who you are, and since we send us a couple of emails every day, you don’t need to say ‘hello’ every time! Have a look at how little information your whole pile of characters actually contains.</p>
<p>This is what I want to receive:</p>
<blockquote><p>Yes, 4pm is fine. See ya!</p></blockquote>
<p>Please, do me a favor and remove all that useless waste from your emails. You don’t need a signature. You don’t need to say hello and goodbye on every email you’re sending. Don’t make me distill your emails to find what is the actual message.</p>
<p><strong>Please try to say what you want to say in as few words as possible!</strong></p>
<p>The post <a href="http://daniellang.net/please-stop-using-email-signatures/">Please stop using email signatures</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/please-stop-using-email-signatures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://daniellang.net/please-stop-using-email-signatures/</feedburner:origLink></item>
		<item>
		<title>Is responsive web design really worth the effort?</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/1JHDHCLkuDA/</link>
		<comments>http://daniellang.net/is-responsive-web-design-really-worth-the-effort/#comments</comments>
		<pubDate>Sat, 29 Dec 2012 02:44:01 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=636</guid>
		<description><![CDATA[<p>I’ve been working on a couple of different websites recently and some of them were designed in a way that they would adapt to various screen resolutions dynamically. Web people usually call this responsive design. I call this headache design and my advise as a programmer and businessman is to make sure you really benefit [...]</p><p>The post <a href="http://daniellang.net/is-responsive-web-design-really-worth-the-effort/">Is responsive web design really worth the effort?</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I’ve been working on a couple of different websites recently and some of them were designed in a way that they would adapt to various screen resolutions dynamically. Web people usually call this <em>responsive design</em>. I call this <em>headache design</em> and my advise as a programmer and businessman is to make sure you really benefit from it before you commit yourself to that paradigm. Here’s why.</p>
<h3></h3>
<h3>What is responsive webdesign?</h3>
<p>In the beginning was The Fixed Width, and The Fixed Width was Great, and the Great was The Fixed Width. It was not until people started to buy iPhones and Androids when troubles started to begin. Users were no longer satisfied with how our carefully crafted web pages looked on their new gadgets. So we built mobile versions of our websites, especially targeting those crippled 320 to 480 pixel devices. But then Steve gave us the iPad and – what is even worse – people loved it and navigated straight to our desktop optimized web applications. So what shall we do? Build tablet-optimized versions of our sites? Who’s going to pay for all this?</p>
<p>The idea of responsive webdesign was born. Instead of building three websites for different devices, let’s just build one that fits all!</p>
<p>Have a look at these great examples of responsiveness:</p>
<ul>
<li><a href="http://colly.com/">colly.com</a></li>
<li><a href="http://seesparkbox.com/">seesparkbox.com</a></li>
<li><a href="http://mangomint.com/">mangomint.com</a> (yep, that’s my own company)</li>
</ul>
<p>Make sure you resize your browser window and note how various elements change fluently (i.e. the navigation menu).</p>
<h3>How it works</h3>
<p>Technically, there are few things to consider in order to make a website responsive:</p>
<ul>
<li>No fixed widths but ratios (i.e. how many parts in a 16 parts wide grid system)</li>
<li>Content organized in floating elements that can rearrange in rows with different number of columns</li>
<li>CSS media queries to selectively show/hide elements and address special issues with lower resolutions</li>
</ul>
<p>This is just the gist of it. There’s much more to say about those techniques, but that’s not the point of this post.</p>
<p>I should mention that there are tons of frameworks, libraries and instructions available that help you get these things right. With all that help and a little bit of practicing, it’s actually not that hard to implement responsive layouts.</p>
<h3>So what’s wrong with responsive webdesign?</h3>
<p>Nothing. I just say that they cause a damn lot of work and you better be sure it’s worth the effort. Here’s a few things to consider:</p>
<ul>
<li><strong>The width issue</strong><br />
Think about how many times you wrote something like ‘width:240px;’ in your last website project. Forget that! Now you have to think in terms of ‘eight-columns’ or ‘six-columns’. Most of the time that works just fine, but sometimes you really want that 365px width. Oh, that’s already more than what you have on the smallest iPhone resolution…</li>
<li><strong>The spacing issue</strong><br />
So let’s show a bunch thumbnails and put a slick 20px margin around. Four in a row, just so that we have the same spacing to the outer box left and right. Looks good, doesn’t it? Except when you resize the browser and everything gets turned around, then that 20 pixel look quite different and now you don’t have that nice spacing anymore.&nbsp;</li>
<li><strong>The content issue<br />
</strong>Noticed that most responsive webdesign tutorials show simple item grids? That is because they are perfectly suited to demonstrate the idea. In the real world, however, there are landing pages, overview pages, product comparison charts, complex registration forms, etc. You really have to make sure that every piece of content adheres to the responsive principles – that means everything should be either resizable or floatable. That’s whole lot of worries for content creators.</li>
<li><strong>The programmer/designer issue</strong><br />
For many year, designers only needed to hand over PSDs to us programmers. That was good because we suck at design things. With responsive layout, that gets a whole lot more complicated. Obviously designers can’t create separate PSDs for every possible screen resolution and every page. Programmers are given much more responsibility to make the final work look good. Since their perception of what looks sufficiently good can be quite different from the designers point of view, there’s usually a lot more back and forth between those two guys.</li>
</ul>
<h3>Do you really need it?</h3>
<p>I am in no way an expert in webdesign generally and responsive design specifically. Real web developers would probably call me a script kiddie or – if they are really evil – a “windows guy”. However, I’ve worked on a couple of dozen non-trivial web applications, most of which did not implement a responsive webdesign and some more recent projects with a responsive layout – after all, I can definitely say that there’s at least a 50% increase in the total amount of time it takes to get the web related stuff done.</p>
<p>Also note, that responsive websites require quite different organizational structures. Content creators must be aware of the restrictions and paradigms. Designer must have a better understanding of how HTML and CSS works. The size of working batches between designers and programmers is much smaller. Communications between those two roles is chattier. All that must be taken into account.</p>
<p>So before you jump onto that responsive train, go ask yourself: is it really worth the effort?</p>
<p><strong>What do you think? Have you had different experiences during your projects?</strong></p>
<p>The post <a href="http://daniellang.net/is-responsive-web-design-really-worth-the-effort/">Is responsive web design really worth the effort?</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/is-responsive-web-design-really-worth-the-effort/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://daniellang.net/is-responsive-web-design-really-worth-the-effort/</feedburner:origLink></item>
		<item>
		<title>How to recover a corrupted RavenDB database</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/4OJC8k6gL7g/</link>
		<comments>http://daniellang.net/how-to-recover-a-corrupted-ravendb-database/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 10:03:15 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=615</guid>
		<description><![CDATA[<p>In the real world, there ain’t no absolute things. Words like ‘never’ are always wrong (notice the recursion?). A RavenDB database should never go corrupt. But it does. In this post, I’ll show you what you can do when you get an error like this: System.InvalidOperationException: Could not open transactional storage First, let’s talk about [...]</p><p>The post <a href="http://daniellang.net/how-to-recover-a-corrupted-ravendb-database/">How to recover a corrupted RavenDB database</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the real world, there ain’t no absolute things. Words like ‘never’ are always wrong (notice the recursion?). A RavenDB database should never go corrupt. But it does. In this post, I’ll show you what you can do when you get an error like this:</p>
<blockquote><p>System.InvalidOperationException: Could not open transactional storage</p>
</blockquote>
<p>First, let’s talk about what could possibly lead to such a problem. As you probably know at this point, RavenDB uses ESENT as it’s storage engine. ESENT is a transactional storage engine that ships with every Windows version since Windows 2000 and powers things like the Active Directory, Windows Search Index or Exchange Server. When you get the above error, there’s almost always something wrong with the ESENT files on the disk.</p>
<p>Personally, I’ve seen 4 different scenarios (I’m sure there are more) that could bring your database into such a corrupted state:</p>
<ul>
<li><strong>Dirty shutdown</strong><br />Power outages, hardware failure or evil admin users could cause the RavenDB process to be killed unexpectedly. When this happens, there is a high chance that the ESENT data file on disk gets corrupted.
<li><strong>Moving between windows versions<br /></strong>If you just copy the data directory (instead of using Smuggler), you will likely end up with ESENT not being able to startup on the new machine.
<li><strong>Live migration of a virtual machine</strong><br />Don’t believe hypervisor vendors like VMware or Citrix when they claim they can securely migrate a running virtual machine. They can’t. I’ve already crushed two databases while doing live migrations.
<li><strong>Upgrading to RavenDB 2.0 unstable</strong><br />If you’re like me and can’t await the official realease of RavenDB 2.0, then please be aware that there could be issues when you upgrade an existing database. </li>
</ul>
<p>I should say at this point, that RavenDB tries to automatically recover the database upon startup when it notices that it wasn’t shut down cleanly. However, that didn’t always work for me and I had to execute some manual steps to get my databases up and running.</p>
<p>Actually, it is quite simple – you just need to learn how to use the tool <strong>esentutl.exe</strong> which comes with Windows.</p>
<p>Here are a few things that you can do:</p>
<h3>Defragmentation</h3>
<p>This is most useful when you moved the data folder between different Windows version. Go into your data folder, open a command prompt and type:</p>
<pre>esentutl /d Data</pre>
<p></p>
<h3>Soft recovery</h3>
<p>On the disk, ESENT maintains all of the data within a single file. In addition to that, every transaction gets written to a log file. Using that log files, ESENT can re-run those operations and recreate a consistent state. Using this command, you should be able to recover from almost all damages:</p>
<pre>esentutl /r RVN /l logs /s system</pre>
<p></p>
<h3>Repair</h3>
<p>When things went really bad and both defragmentation and recovery didn’t help, you can fall back to a forced repair. Only consider this option when a recovery didn’t work. If you can, restore from a backup. If you can’t, this command can save your butt:</p>
<pre>esentutl /p Data</pre>
<p></p>
<p>Of course the best is to avoid running into these situations in the first place. However, <strike>if</strike> when you have this scaring “Could not open transactional storage” exception, it is good to know what to do!</p>
<p>The post <a href="http://daniellang.net/how-to-recover-a-corrupted-ravendb-database/">How to recover a corrupted RavenDB database</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/how-to-recover-a-corrupted-ravendb-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://daniellang.net/how-to-recover-a-corrupted-ravendb-database/</feedburner:origLink></item>
		<item>
		<title>Don’t forget to unit-test your mappings</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/zUrVrIXakWs/</link>
		<comments>http://daniellang.net/dont-forget-to-unit-test-your-mappings/#comments</comments>
		<pubDate>Sun, 11 Nov 2012 16:16:13 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=610</guid>
		<description><![CDATA[<p>I never bothered to unit test the view model mappings in my web applications. Most of the time, I would use AutoMapper anyway and everything just works. However, AutoMapper can be kind of dangerous because things are so automated, you don’t see what’s going on. Let’s look at an issue I just ran into that [...]</p><p>The post <a href="http://daniellang.net/dont-forget-to-unit-test-your-mappings/">Don&rsquo;t forget to unit-test your mappings</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I never bothered to unit test the view model mappings in my web applications. Most of the time, I would use <a href="https://github.com/AutoMapper/AutoMapper">AutoMapper</a> anyway and everything just works. However, AutoMapper can be kind of dangerous because things are so automated, you don’t see what’s going on.</p>
<p>Let’s look at an issue I just ran into that caused serious data loss.</p>
<p>First, I have a domain model class <em>Person</em> which inherits <em>Contact</em>.</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/11/image.png" alt="image" width="318" height="200" border="0" /></p>
<p>Then, there is a <em>PersonViewModel</em> which inherits <em>ContactViewModel</em>.</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/11/image1.png" alt="image" width="351" height="206" border="0" /></p>
<p>And my controller couldn’t be easier, it’s basically just this:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/11/image2.png" alt="image" width="374" height="268" border="0" /></p>
<p>Please pay attention to how we update the person. We just load the person from RavenDB and then use AutoMapper to update the properties with the ones from the view model. RavenDB automatically tracks the changes and updates the document in the database.</p>
<p>Good. Now we need to configure AutoMapper. Before I show you the code, please be aware of the contact’s property <em>CreatedOn</em>. There are valid reasons for which I don’t want this property to be mapped when going from ContactViewModel to Contact. So we have to ignore it:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/11/image3.png" alt="image" width="406" height="107" border="0" /></p>
<p>This looks great and it uses AutoMapper’s <a href="https://github.com/AutoMapper/AutoMapper/wiki/Mapping-inheritance">inheritance mapping</a> feature.</p>
<p><strong>Except… it doesn’t work!</strong></p>
<p>The problem here is that because of how AutoMapper prioritizes the mapping, it would actually map the <em>CreatedOn</em> property when going from <em>PersonViewModel</em> to <em>Person</em>. In other words, it didn’t inherit the .Ignore().</p>
<p>What was particularly bad for me was that I only noticed this when I had a lot of documents in RavenDB which had CreatedOn set to “0001-01-01 00:00”… hmm. It doesn’t matter that I think this was a bad design decision in AutoMapper and somehow should let <a href="http://lostechies.com/jimmybogard/">Jimmy Bogard</a> now about that – the data is gone and I can only restore it from backups.</p>
<p>How could I have prevented that? The answer is trivially simple: <em>I should have tested my assumption about how AutoMapper works</em>.</p>
<p>Here is how a test could have looked like:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/11/image4.png" alt="image" width="691" height="361" border="0" /></p>
<p>Next time, I’ll make sure I unit-test my mappings and I hope you do so as well.</p>
<p>The post <a href="http://daniellang.net/dont-forget-to-unit-test-your-mappings/">Don&rsquo;t forget to unit-test your mappings</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/dont-forget-to-unit-test-your-mappings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://daniellang.net/dont-forget-to-unit-test-your-mappings/</feedburner:origLink></item>
		<item>
		<title>RavenDB: Field boosting with full text search</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/HbYNaLJNRic/</link>
		<comments>http://daniellang.net/ravendb-field-boosting-with-full-text-search/#comments</comments>
		<pubDate>Mon, 29 Oct 2012 20:27:05 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=602</guid>
		<description><![CDATA[<p>Now you have a CRM-type application with the notion of persons and companies and you want to give your users a powerful way to search over those contacts. You could use a multi-map index like this: Searching for contacts then goes like this: Which gives you all the contacts, both persons and companies that somehow [...]</p><p>The post <a href="http://daniellang.net/ravendb-field-boosting-with-full-text-search/">RavenDB: Field boosting with full text search</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Now you have a CRM-type application with the notion of persons and companies and you want to give your users a powerful way to search over those contacts. You could use a multi-map index like this:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://daniellang.net/wp-content/uploads/2012/10/image1.png" width="465" height="518"></p>
<p>Searching for contacts then goes like this:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://daniellang.net/wp-content/uploads/2012/10/image2.png" width="552" height="105"></p>
<p>Which gives you all the contacts, both persons and companies that somehow match the term <em>q</em>.</p>
<p>Now, suppose we have a company with the name <strong>Contoso Ltd </strong>and a person <strong>John Miller</strong> who works for that company. In addition to that, we have tagged the person with ‘contoso’. How would you like the results being ordered if we search for the term ‘contoso’?</p>
<p>This is what RavenDB gives you by default: John Miller; Contoso Ltd</p>
<p>… which is not very good, because apparently you want to have the company on the first position since your search term exactly matched the company name. However, the score of John Miller was higher because we matched the term twice (in the company name and in the tags). So what we have to do is to boost the field ‘name’ in the index, right?</p>
<p>Let’s try this:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://daniellang.net/wp-content/uploads/2012/10/image3.png" width="500" height="517"></p>
<p>Unfortunately, this doesn’t work here as well. The reason for this has to do with how Lucene does scoring when using a PrefixQuery (which we actually do since we have StartsWith). If we, for instance, change the StartsWith to Equals it would give us the expected results, but this isn’t what we want. </p>
<p>The Real Solution™ is to do the boosting at query time, instead of index time. Let’s change the search query to this:</p>
<p><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://daniellang.net/wp-content/uploads/2012/10/image4.png" width="549" height="90"></p>
<p>This time, we’re boosting the field ‘Name’ by a factor of 10 at query time. This makes that match powerful enough, so that even though <strong>John Miller</strong> has two matching terms, we will still get <strong>Contoso Ltd</strong> first because we boosted its score.</p>
<p>We can even further enhance this query and assign different boost factors to all of the three fields. That way we can build very powerful searching capabilities into our applications.</p>
<p>The post <a href="http://daniellang.net/ravendb-field-boosting-with-full-text-search/">RavenDB: Field boosting with full text search</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/ravendb-field-boosting-with-full-text-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://daniellang.net/ravendb-field-boosting-with-full-text-search/</feedburner:origLink></item>
		<item>
		<title>Always run Visual Studio as Administrator in Windows 8</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/jPhcxcC56nA/</link>
		<comments>http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/#comments</comments>
		<pubDate>Thu, 11 Oct 2012 20:56:26 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=592</guid>
		<description><![CDATA[<p>Back in old Windows 7 days when we wanted to make Visual Studio always launch as administrator we only had tick the checkbox “Always run as Administrator” on Compatibility tab of the devenv.exe file properties dialog. Now this doesn’t work anymore in Windows 8! First problem is the absence of the Compatibility tab. Second problem [...]</p><p>The post <a href="http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/">Always run Visual Studio as Administrator in Windows 8</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Back in old Windows 7 days when we wanted to make Visual Studio always launch as administrator we only had tick the checkbox “Always run as Administrator” on Compatibility tab of the devenv.exe file properties dialog.</p>
<p>Now this doesn’t work anymore in Windows 8!</p>
<p>First problem is the absence of the Compatibility tab. Second problem is that once you managed to make the tab re-appear using a registry hack it still doesn’t work quite well when you have Visual Studio 2012 installed along with Visual Studio 2010. There is also an extension called VSCommands which promises to make it work, but it did not in my case.</p>
<p>Here is a simple way to <strong>make Visual Studio always launch as Administrator in Windows 8</strong>:</p>
<ol>
<li>Go to HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers</li>
<li>Add a <em>String Value</em>and set its name to “C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe”. Set its value to “RUNASADMIN”.<a href="http://daniellang.net/wp-content/uploads/2012/10/SNAGHTML86ff6b93.png"><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="SNAGHTML86ff6b93" src="http://daniellang.net/wp-content/uploads/2012/10/SNAGHTML86ff6b93_thumb.png" alt="SNAGHTML86ff6b93" width="640" height="380" border="0" /></a></li>
<li>Do the same again but use &#8220;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe&#8221; as the name.</li>
<li>Done! Now every time you start Visual Studio it runs as Administrator!</li>
</ol>
<p>The post <a href="http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/">Always run Visual Studio as Administrator in Windows 8</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://daniellang.net/always-run-visual-studio-as-administrator-in-windows-8/</feedburner:origLink></item>
		<item>
		<title>Query database size in RavenHQ</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/rp06y3f7M6E/</link>
		<comments>http://daniellang.net/query-database-size-in-ravenhq/#comments</comments>
		<pubDate>Tue, 09 Oct 2012 16:15:32 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ravendb]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=583</guid>
		<description><![CDATA[<p>I decided to give RavenHQ a try and use it for our upcoming website (although it still hasn’t European instances available which sucks very much). I’m happy to pay for the service, but since a free plan is available I want to start with this one and upgrade to a paid when necessary. The free [...]</p><p>The post <a href="http://daniellang.net/query-database-size-in-ravenhq/">Query database size in RavenHQ</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I decided to give RavenHQ a try and use it for our upcoming website (although it still hasn’t European instances available which <em>sucks very much</em>). I’m happy to pay for the service, but since a free plan is available I want to start with this one and upgrade to a paid when necessary.</p>
<p>The free plan is limited to 15MB and it has a hard storage limit, which means that you will get exceptions on write operations as soon as you hit this wall.</p>
<p>I don’t want my visitor to be the first to notice that when they try to leave a comment. I also don’t want to check the size regularly on my own. What I want is an email that tells me I should enter my credit card details and upgrade to a paid plan as soon as my database reaches 13MB or so.</p>
<p>To do so, I decided to check the database size upon startup and send myself an email when some threshold is reached.</p>
<p>Admittedly, it took me some time to figure how I can query the current size of the database… Here is the code – hopefully it will be useful for someone as well:</p>
<p><img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/10/image.png" alt="image" width="558" height="293" border="0" /></p>
<p>Edit: <a href="http://www.jonathanchannon.com/">Jonathan Channon</a> contacted me and told me that he has already done the same before. Actually, he has a more advanced approach and deletes old documents to stay withing the limit (I don&#8217;t want to do this but it&#8217;s interesting). Take a look at his blog post here: <a href="http://blog.jonathanchannon.com/2012/09/21/nancyfx-ravendb-nerddinner-and-me/">http://blog.jonathanchannon.com/2012/09/21/nancyfx-ravendb-nerddinner-and-me/</a></p>
<p>The post <a href="http://daniellang.net/query-database-size-in-ravenhq/">Query database size in RavenHQ</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/query-database-size-in-ravenhq/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://daniellang.net/query-database-size-in-ravenhq/</feedburner:origLink></item>
		<item>
		<title>How to automate TeamCity backups using its REST API</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/Mm6qsMUGIsg/</link>
		<comments>http://daniellang.net/how-to-automate-teamcity-backups-using-its-rest-api/#comments</comments>
		<pubDate>Sun, 09 Sep 2012 17:22:57 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=568</guid>
		<description><![CDATA[<p>In the past we have been running our TeamCity CI server on an Amazon EC2 instance. This has been kind of cool, because it allowed us to use something simple as Skeddly to backup the whole machine once a day. However, it was also quite expensive (almost 100$ for the small EC2 instance per month) [...]</p><p>The post <a href="http://daniellang.net/how-to-automate-teamcity-backups-using-its-rest-api/">How to automate TeamCity backups using its REST API</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the past <a href="http://mangomint.com">we</a> have been running our TeamCity CI server on an Amazon EC2 instance. This has been kind of cool, because it allowed us to use something simple as <a href="http://skeddly.com/">Skeddly</a> to backup the whole machine once a day. However, it was also quite expensive (almost 100$ for the small EC2 instance per month) and builds didn’t perform very well (only 1GHz CPU and 1.7GB of RAM). Fortunately I had an <em>old</em> laptop with a Core2Duo, 4GB Ram and an SSD lying around and decided this would be our new TeamCity server.</p>
<p>Setting up TeamCity was quick and easy, after a couple of hours I had all our projects working and guess what, builds that took more than 5 minutes before now finished within a minute or two. This was all amazing, except that we had no good backup anymore. TeamCity doesn’t provide a way to schedule automated backups but it has a REST API that one can use to build his own automated solution.</p>
<p>I have hacked together <a href="https://github.com/mangomint/TCAutoBackup">a small command line tool</a> that you can use to automate TeamCity backups using its REST API. In addition to that, I automatically ship the backup files to Amazon S3. If you want to do the same, read on, I’ll show you a few simple steps.</p>
<p>Here is, what you need to do:</p>
<ol>
<li>Configure the default TeamCity backup path by edition the <em>backup-config.xml</em> file in %<em>TEAMCITY_DATA_PATH%/config/.</em> Let’s use something like <em>C:/teamcity-backup<br />
</em></li>
<li>Create a backup user with administrative rights. This will be the one we will use to authenticate over http later.</li>
<li>Go to <a href="https://github.com/mangomint/TCAutoBackup">https://github.com/mangomint/TCAutoBackup</a>, clone and compile the command line tool. Now copy the files <em>TCAutoBackup.exe</em> and <em>TCAutoBackup.exe.config</em> to a new directory on your build-server, let’s say <em>C:/teamcity-backup-tool.</em>Make sure .NET Framework 4.5 is installed on your build-server.&nbsp;</li>
<li>Edit the <em>TCAutoBackup.exe.config</em> file to your needs. Here’s mine:<br />
<img style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/09/image1.png" alt="image" width="510" height="308" border="0" /><br />
Don’t forget to run the program once to verify that everything works.</li>
<li>Now, let’s schedule the execution. One option is to use something like Windows Task Scheduler or whatever other enterprise scheduling system you prefer. Another option is to use TeamCity itself, which is what I did: Just create a new project and use the Command Line runner to run the <em>TCAutoBackup.exe</em>file. In addition to that, you will want to create build trigger that schedules the backup to build on a regular basis (i.e. once a day).&nbsp;</li>
<li>Last thing to do is to setup offsite-shipping for your backup files. Some prefer to carry around external storage drives, others (like me) are lazy and want this to be done by someone else, preferably a computer program. I personally like <a href="http://www.cloudberrylab.com">CloudBerry Amazon S3 Backup</a>. It’s easy to use and let’s you configure real-time monitoring for a folder, so that every time a new backup file is created it will ship it to your S3 bucket automatically. What is nice as well is that it sends you an email afterwards.</li>
</ol>
<p>Congrats, you should now have automated your TeamCity backups!</p>
<p><strong>Just keep in mind: You don’t have a backup until you successfully tested the restore procedure!</strong></p>
<p>The post <a href="http://daniellang.net/how-to-automate-teamcity-backups-using-its-rest-api/">How to automate TeamCity backups using its REST API</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/how-to-automate-teamcity-backups-using-its-rest-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://daniellang.net/how-to-automate-teamcity-backups-using-its-rest-api/</feedburner:origLink></item>
		<item>
		<title>Why NuGet package update is seriously broken</title>
		<link>http://feedproxy.google.com/~r/daniellangnet/~3/6N5JORT63j0/</link>
		<comments>http://daniellang.net/why-nuget-package-update-is-seriously-broken/#comments</comments>
		<pubDate>Wed, 04 Jul 2012 17:05:13 +0000</pubDate>
		<dc:creator>Daniel Lang</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fail]]></category>

		<guid isPermaLink="false">http://daniellang.net/?p=560</guid>
		<description><![CDATA[<p>This was a bloody one, so here is an advice: Pay extra attention when you use NuGet package manager and update a dependency that is used in more than one of your projects! So, why is it broken? Let me explain… This is our solution structure: Both highlighted projects use the NuGet package “RavenDB.Embedded”. Recently [...]</p><p>The post <a href="http://daniellang.net/why-nuget-package-update-is-seriously-broken/">Why NuGet package update is seriously broken</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>This was a bloody one, so here is an advice:</p>
<p><strong>Pay extra attention when you use NuGet package manager and update a dependency that is used in more than one of your projects!</strong></p>
<p>So, why is it broken? Let me explain…</p>
<p>This is our solution structure:</p>
<p><img style="background-image: none; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://daniellang.net/wp-content/uploads/2012/07/image.png" alt="image" width="261" height="253" border="0" /></p>
<p>Both highlighted projects use the NuGet package “RavenDB.Embedded”. Recently we had an issue with a customer that was fixed in build 2024. So, I used the package manager window to update to RavenDB build 2025:</p>
<p><img style="background-image: none; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML179945e1" src="http://daniellang.net/wp-content/uploads/2012/07/SNAGHTML179945e1.png" alt="SNAGHTML179945e1" width="800" height="450" border="0" /></p>
<p>I then pushed the commit to our repository and TeamCity started the psake task to build and deploy the package. <em>This worked great – the issue was fixed!</em></p>
<p>Since then (about 2 weeks) we shipped about 30 new builds of our software and had no problems. However, the issue re-appeared today and it was exactly the same problem that we had back then.</p>
<p>After some headaches I found out that for some reason we were deploying RavenDB version 2005 again, although the NuGet package clearly was on build 2025!</p>
<p>I have to admit – it took me some time to figure this… <em><strong>the problem was that NuGet update works per project and not for the whole solution!</strong></em> So, while one project was on version 2025, the other still was on 2005:</p>
<p><img style="background-image: none; margin: 0px 0px 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="SNAGHTML17b85ede" src="http://daniellang.net/wp-content/uploads/2012/07/SNAGHTML17b85ede.png" alt="SNAGHTML17b85ede" width="800" height="450" border="0" /></p>
<p>I can’t get my head around why I would want to update only one project but leave the other untouched. This makes absolutely no sense to me and apparently it causes some issues with <em>msbuild</em> as well (was shipping the newer version before but then returned for no reason).</p>
<p>I hope that this weird behavior will be fixed with an upcoming NuGet version (this was 2.0), but until then <strong>we must remember to update NuGet packages in every project of the solution</strong>!</p>
<p>The post <a href="http://daniellang.net/why-nuget-package-update-is-seriously-broken/">Why NuGet package update is seriously broken</a> appeared first on <a href="http://daniellang.net">Daniel Lang</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://daniellang.net/why-nuget-package-update-is-seriously-broken/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://daniellang.net/why-nuget-package-update-is-seriously-broken/</feedburner:origLink></item>
	</channel>
</rss>
