<?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>emphess .NET &#187; .NET</title>
	<atom:link href="http://www.emphess.net/category/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emphess.net</link>
	<description>Freshly Draught Code</description>
	<lastBuildDate>Fri, 11 Nov 2011 11:57:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>LESS Grid CSS for Fluid Width Grids</title>
		<link>http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/</link>
		<comments>http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 02:34:15 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=278</guid>
		<description><![CDATA[I&#8217;m a huge fan of LESS. CSS is nice, but using LESS makes your files so much cleaner. Now I had to cope with some grid systems today, and I figured that many online grid generators are either broken, down or buggy. Perhaps it&#8217;s just not my lucky day. Anyway, the cool thing is that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a huge fan of <a href="http://lesscss.org/">LESS</a>. CSS is nice, but using LESS makes your files so much cleaner. Now I had to cope with some grid systems today, and I figured that many online grid generators are either broken, down or buggy. Perhaps it&#8217;s just not my lucky day. Anyway, the cool thing is that those grid CSS files are somewhat simple &#8211; just some basic math.</p>
<h2>LESS CSS?! What?</h2>
<p>Using LESS <em>mixins</em>, we can replace cumbersome CSS with a few simple statements. A mixin basically copies all properties over. For example, the following LESS will produce really huge, red text if applied:</p>
<pre class="brush: php">
.huge{
    font-size: 80px;
}

.hugeWarning{
    .huge;
    color: red;
}
</pre>
<p>OK, nice, but the CSS equivalent wouldn&#8217;t be very different. But you can also <strong>parametrize mixins</strong>, the classical example (taken directly from the LESS website) being rounded corners:</p>
<pre class="brush: php">
.rounded_corners (@radius: 5px) {
  -moz-border-radius: @radius;
  -webkit-border-radius: @radius;
  border-radius: @radius;
}

#header {
  .rounded_corners;
}

#footer {
  .rounded_corners(10px);
}
</pre>
<h2>LESS in ASP .NET</h2>
<p>If you want to use LESS from your shiny new ASP.NET MVC3 application, I suggest you grab a copy of <a href="https://github.com/jetheredge/SquishIt">Justin Etheredge&#8217;s brilliant zero-friction SquishIt</a> library which compiles LESS to CSS, combines the files and minimizes them. Oh, yes, and of course also handles <a href="http://www.codethinked.com/post/2010/05/26/SquishIt-The-Friendly-ASPNET-JavaScript-and-CSS-Squisher.aspx">JavaScript combining and minification</a>!</p>
<p>Now, since LESS also supports some mathematical operations, we can do all the nasty grid-calculation using LESS. For a fluid grid, this becomes something like this:</p>
<pre class="brush: php">
/* Fluid grid based on 960.gs syntax
This grid contains ONLY the fluid-container_12 class and it&#039;s associated grid, pull, push, suffix and prefix classes. Note that this CSS does not support nesting of grids.
*/

@columnCount: 12; // When you increase this, you also need to add some more classes below
@halfGutter: 1%; // half of the gutter width

.fluid-container_12 {
	margin-left: 0px;
	margin-right: 0px;
	width: 100%;
}

.grid (@n: 1)
{
	width: @n * 100% / @columnCount - 2.0 * @halfGutter;
	margin-left: @halfGutter;
	margin-right: @halfGutter;
}

.fluid-container_12 .grid_1{ .grid(1); }
.fluid-container_12 .grid_2{ .grid(2); }
.fluid-container_12 .grid_3{ .grid(3); }
.fluid-container_12 .grid_4{ .grid(4); }
.fluid-container_12 .grid_5{ .grid(5); }
.fluid-container_12 .grid_6{ .grid(6); }
.fluid-container_12 .grid_7{ .grid(7); }
.fluid-container_12 .grid_8{ .grid(8); }
.fluid-container_12 .grid_9{ .grid(9); }
.fluid-container_12 .grid_10{ .grid(10); }
.fluid-container_12 .grid_11{ .grid(11); }
.fluid-container_12 .grid_12{ .grid(12); }

.prefix(@n:1)
{
	padding-left: @n * 100% / @columnCount;
}

.fluid-container_12 .prefix_1 { .prefix(1); }
.fluid-container_12 .prefix_2 { .prefix(2); }
.fluid-container_12 .prefix_3 { .prefix(3); }
.fluid-container_12 .prefix_4 { .prefix(4); }
.fluid-container_12 .prefix_5 { .prefix(5); }
.fluid-container_12 .prefix_6 { .prefix(6); }
.fluid-container_12 .prefix_7 { .prefix(7); }
.fluid-container_12 .prefix_8 { .prefix(8); }
.fluid-container_12 .prefix_9 { .prefix(9); }
.fluid-container_12 .prefix_10 { .prefix(10); }
.fluid-container_12 .prefix_11 { .prefix(11); }
.fluid-container_12 .prefix_12 { .prefix(12); }

.suffix(@n:1)
{
	padding-right: @n * 100% / @columnCount;
}

.fluid-container_12 .suffix_1 { .suffix(1); }
.fluid-container_12 .suffix_2 { .suffix(2); }
.fluid-container_12 .suffix_3 { .suffix(3); }
.fluid-container_12 .suffix_4 { .suffix(4); }
.fluid-container_12 .suffix_5 { .suffix(5); }
.fluid-container_12 .suffix_6 { .suffix(6); }
.fluid-container_12 .suffix_7 { .suffix(7); }
.fluid-container_12 .suffix_8 { .suffix(8); }
.fluid-container_12 .suffix_9 { .suffix(9); }
.fluid-container_12 .suffix_10 { .suffix(10); }
.fluid-container_12 .suffix_11 { .suffix(11); }
.fluid-container_12 .suffix_12 { .suffix(12); }

.push(@n:1)
{
	left: @n * 100% / @columnCount;
}

.fluid-container_12 .push_1 { .push(1); }
.fluid-container_12 .push_2 { .push(2); }
.fluid-container_12 .push_3 { .push(3); }
.fluid-container_12 .push_4 { .push(4); }
.fluid-container_12 .push_5 { .push(5); }
.fluid-container_12 .push_6 { .push(6); }
.fluid-container_12 .push_7 { .push(7); }
.fluid-container_12 .push_8 { .push(8); }
.fluid-container_12 .push_9 { .push(9); }
.fluid-container_12 .push_10 { .push(10); }
.fluid-container_12 .push_11 { .push(11); }
.fluid-container_12 .push_12 { .push(12); }

.pull(@n:1)
{
	right: @n * 100% / @columnCount;
}

.fluid-container_12 .pull_1 { .pull(1); }
.fluid-container_12 .pull_2 { .pull(2); }
.fluid-container_12 .pull_3 { .pull(3); }
.fluid-container_12 .pull_4 { .pull(4); }
.fluid-container_12 .pull_5 { .pull(5); }
.fluid-container_12 .pull_6 { .pull(6); }
.fluid-container_12 .pull_7 { .pull(7); }
.fluid-container_12 .pull_8 { .pull(8); }
.fluid-container_12 .pull_9 { .pull(9); }
.fluid-container_12 .pull_10 { .pull(10); }
.fluid-container_12 .pull_11 { .pull(11); }
.fluid-container_12 .pull_12 { .pull(12); }
</pre>
<p>Nifty, huh?</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=LESS+Grid+CSS+for+Fluid+Width+Grids+http%3A%2F%2Femphess.net%2F%3Fp%3D278" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/&amp;title=LESS+Grid+CSS+for+Fluid+Width+Grids" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/&amp;title=LESS+Grid+CSS+for+Fluid+Width+Grids" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/&amp;t=LESS+Grid+CSS+for+Fluid+Width+Grids" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/11/12/less-grid-css-for-fluid-width-grids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create High-Quality PDFs With Razor View Engine and LaTeX</title>
		<link>http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/</link>
		<comments>http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 17:48:23 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[MVC3]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[Razor]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=257</guid>
		<description><![CDATA[ASP.NET MVC3 is a blast! If you haven&#8217;t tried it, you definitely should &#8211; it&#8217;s really fun to work with and brings so many cool new features! Now that the MVC3 Release Candidate is out, there&#8217;s practically nothing missing. Most importantly however, MVC3 introduces the Razor View Engine and separates MVC and WebPages, so the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.asp.net/mvc/mvc3">ASP.NET MVC3</a> is a blast! If you haven&#8217;t tried it, you definitely should &ndash; it&#8217;s really fun to work with and brings so many cool new features! Now that the <a href="http://weblogs.asp.net/scottgu/archive/2010/11/09/announcing-the-asp-net-mvc-3-release-candidate.aspx">MVC3 Release Candidate</a> is out, there&#8217;s practically nothing missing.</p>
<p>Most importantly however, MVC3 introduces the <a href="http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx">Razor View Engine</a> and separates MVC and WebPages, so the web rendering is no longer hard-wired into the ASP.NET subsystem.</p>
<p>Apart from its much cleaner syntax, Razor is also more flexible and it&#8217;s open source. <a href="http://www.fidelitydesign.net/">Matthew Abbot</a> and <a href="http://buildstarted.com">Ben of BuildStarted.com</a> have written some interesting articles on how to <a href="http://www.fidelitydesign.net/?p=208">use Razor without MVC</a> and even <a href="http://buildstarted.com/2010/09/29/razor-view-engine-without-mvc-at-all/">without ASP.NET at all</a>.</p>
<h2>PDFs vs. HTML</h2>
<p>Now, what does all that have to do with PDFs? Writing to PDFs itself isn&#8217;t necessarily too hard &ndash; you can easily <a href="http://www.devshed.com/c/a/Java/Creating-Simple-PDF-Files-With-iTextSharp/1/">draw some text</a> here and there or draw lines, for example using the excellent <a href="http://sourceforge.net/projects/itextsharp/">iTextSharp</a> library. But the real deal is typesetting!<a href="http://www.emphess.net/wp-content/uploads/2010/11/p2.png"><img src="http://www.emphess.net/wp-content/uploads/2010/11/p2.png" alt="" title="p2" width="496" height="249" class="alignleft size-full wp-image-268" /></a></p>
<p>Unfortunately, HTML and paper don&#8217;t make a very good fit. Breaking HTML tables across pages, for example, is an insufferable pain. HTML wasn&#8217;t made with paper in mind &#8211; a good thing for HTML, and a good reason not to abuse it for printing PDFs.</p>
<h2>Introducing RazorTex</h2>
<p>Now, Razor makes only a few assumptions about the type of data it renders &#8211; it doesn&#8217;t really have to be HTML&#8230; With <a href="http://github.com/cmenge/RazorTex/">RazorTex</a>, you can create LaTeX-Views on the fly instead! A word of warning though: RazorTex is extremely young and unstable &#8211; more sample code than anything else &#8211; so be prepared! There&#8217;s a ton of features missing, but it works. If you&#8217;re ready for a rather rough ride, go ahead! </p>
<p>So how does it work, behind the scenes? RazorTex will use the Razor engine to compile code into a LaTeX file. A sample section from a <code>.cstex</code> file might look like this:</p>
<pre class="brush: php">
\frac{@Model.Factor.ToString(&quot;F2&quot;)}{@Model.Denominator.ToString(&quot;F2&quot;)} &amp;= @Model.Result.ToString(&quot;F2&quot;) \\
\int_{@Model.LowerBound}^{@Model.UpperBound} @Model.Expression @Model.IntegrationVariable &amp;= @Model.IntegrationResult \\
</pre>
<div style="float: right;">
<a href="http://www.emphess.net/wp-content/uploads/2010/11/p1.png"><img src="http://www.emphess.net/wp-content/uploads/2010/11/p1.png" alt="" title="p1" width="248" height="351" class="alignleft size-full wp-image-267" /></a>
</div>
<p>The <code>'&#038;='</code> and <code>'\\'</code> are special LaTeX-Commands, an alignment character and a line break, respectively. </p>
<p>If you don&#8217;t know LaTeX, the syntax can be really terrifying at first. However, there is no doubt LaTeX is extremely powerful when it comes to <a href="http://www.tug.org/texshowcase/">typesetting complicated document layouts</a>. For example, it supports high-quality text rendering with <a href="http://en.wikipedia.org/wiki/Microtypography">microtypography</a>, breaking tables across pages, typesetting mathematical formulas and rendering vector images, to name only a few. There are many additional packages you can use for practically any type of typesetting problem.</p>
<div style="clear: both;"></div>
<h2>Running the Sample</h2>
<p>Unfortunately, there are some smaller obstacles when running the sample. Also, you&#8217;ll have to install a bunch of things:</p>
<ol>
<li>Download and install <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a920ccee-1397-4feb-824a-2dfefee47d54&#038;displaylang=en">ASP.NET MVC3 Release Candidate</a> from Microsoft. This includes the Razor view engine</li>
<li>Download and install <a href="http://miktex.org/2.8/setup">MiKTeX 2.8</a></li>
<li>Download and install <a href="http://www.winshell.de/">WinShell for LaTeX</a>, an IDE for LaTeX [recommended]</li>
<li>Before running the sample, open the two included sample .TeX files and open them with WinShell. Run the PDF Compiler. This will install the required packages. <strong>If you don&#8217;t install the packages, the sample might dead-lock!</strong></li>
<li>Adjust the settings in app.config according to your needs and create the temporary and output folders.</li>
<li>Finally, the application should run and create great pdfs from a console application&hellip;</li>
</ol>
<h2>The Architecture</h2>
<p>Let&#8217;s take a quick look at the architecture of the Razor pipeline. Most importantly, Razor views are compiled &#8211; a huge advantage when you need to render a lot files with similar structure. However, we need to care for the compilation ourselves. Fortunately, <a href="http://blog.andrewnurse.net/CommentView,guid,6acc0b07-0db5-4353-b375-fbe60a209bb1.aspx">Andrew Nurse</a> has already accomplished that for us. For details, refer to his article. In short, we read the <code>.cstex</code> file, create a RazorParser and throw in our template string. This will create C# code which in turn can be compiled to binary using <code>CodeDom.GenerateCodeFromCompileUnit</code>. Of course, there are some subtleties involved such as assigning the correct base class, importing some namespaces, and so forth.</p>
<p>Once they are compiled, executing the latex view is blazing fast, but compilation takes some time. Therefore, it&#8217;s a good idea to cache these. Right now, there is some caching in RazorFlux, but it&#8217;s probably a good idea to compile all the latex-views in one go (and into a single assembly) &#8211; at least, that&#8217;s the way ASP.NET does it.</p>
<h2>Additional Features, LatexHelper</h2>
<p>Two particularly helpful features in HTML are the <code>HtmlHelper</code> and <code>UrlHelper</code> extensions. Of course, they don&#8217;t make a lot of sense in LaTeX, but there are some LaTeX-features where a custom helper would come in handy &#8211; a <code>LatexHelper</code>!?</p>
<p>Indeed, we can inject our own helpers through the base class:</p>
<pre class="brush: php">
Type baseType = (modelType == null)
            ? typeof(LatexTemplate)
            : typeof(LatexTemplate&lt;&gt;).MakeGenericType(modelType);

generator.GeneratedClass.BaseTypes.Add(baseType);

public abstract class LatexTemplate : ILatexTemplate
{
    public LatexHelper Latex { get; set; }
    public bool SuppressEmptyLines { get; set; }
}
</pre>
<p>So far, the LatexHelper is used primarily for &#8220;display templates&#8221;. Also, the LatexHelper certainly contains the worst hacks in the code. More about that later.</p>
<h2>Drawbacks</h2>
<p>Some disadvantages shouldn&#8217;t go unmentioned:</p>
<ul>
<li>While Razor doesn&#8217;t seem to make too many assumptions, it does assume that line breaks don&#8217;t play a role &#8211; true for HTML but damn wrong for LaTeX. I have had some trouble with that, but nothing that can&#8217;t be solved in the <code>.cstex</code> file. Still looking for a better solution though.</li>
<li>Pdflatex isn&#8217;t too fast &#8211; there might be faster solutions for creating PDFs, but the quality of pdflatex is very high.</li>
<li>It seems impossible to get pdflatex to work with streams instead of files, so you&#8217;ll have to write temporary files &#8211; no big deal, but a little painful. If anybody knows how to it, I&#8217;d be glad to know!</li>
</ul>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Create+High-Quality+PDFs+With+Razor+View+Engine+and+LaTeX+http%3A%2F%2Femphess.net%2F%3Fp%3D257" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/&amp;title=Create+High-Quality+PDFs+With+Razor+View+Engine+and+LaTeX" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/&amp;title=Create+High-Quality+PDFs+With+Razor+View+Engine+and+LaTeX" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/&amp;t=Create+High-Quality+PDFs+With+Razor+View+Engine+and+LaTeX" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Object-Document Mismatch: MongoDB and db4o with Linq</title>
		<link>http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/</link>
		<comments>http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/#comments</comments>
		<pubDate>Wed, 05 May 2010 15:43:07 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[db4o]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[NoSQL]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=232</guid>
		<description><![CDATA[Rob Conery recently wrote about using MongoDB with Linq. I was really intrigued by the fact that you can use elegant, readable, type-safe Linq-queries to access MongoDB document database. To be honest, I had no clue what an object database really is, but when it speaks Linq it must be cool, I thought. So I [...]]]></description>
			<content:encoded><![CDATA[<p>Rob Conery recently <a href="http://blog.wekeroad.com/2010/03/04/using-mongo-with-linq">wrote about using MongoDB with Linq</a>. I was really intrigued by the fact that you can use elegant, readable, type-safe Linq-queries to access <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB document database</a>. To be honest, I had <strong>no clue</strong> what an <strong>object database</strong> really is, but when it speaks Linq it must be cool, I thought. </p>
<p>So I dug a bit deeper into MongoDB and NoRM, which is a nifty C# driver for MongoDB developed by <a href="http://andrewtheken.com/">Andrew Theken</a> and several others. You might want to <a href="http://github.com/atheken/NoRM">grab a copy at github</a>, where you can see how incredibly active the project is! Now, back to the evaluation: what is the best way to evaluate a database? Of course, build <a href="http://www.backlink-tracker.net/">a live product using it</a>!</p>
<p>Since I was completely abusing db4o for said project (in fact, I am storing something you&#8217;d call documents there), I decided that this would be a great candidate for a migration. So now we&#8217;re migrating from an object database to a document database and from an ACID database to a NoSQL solution.</p>
<p>MongoDB is considered a <a href="http://nosql-database.org/">NoSQL</a> solution, <a href="http://www.kellblog.com/2010/04/11/yes-virginia-marklogic-is-a-nosql-system/">while db4o is considered &#8216;soft&#8217; NoSQL</a> &#8211; see Stefan&#8217;s comment at the bottom. Why the distinction &#8211; both do not rely on, support or use SQL whatsoever?! But then again, that is not what the Term &raquo;<em>NoSQL</em>&laquo; is all about. It&#8217;s probably one of the most misleading terms ever coined and perhaps it should read &raquo;Not ACID&laquo; or just &raquo;Persistence without Prejudgement, <em>PwoP</em>&laquo;. db4o makes ACID guarantees, comes from an embedded background and offers single-server durability while MongoDB is made for the net, does not have single-server durability, supports MapReduce and is driven by JavaScript. </p>
<p>Hell, they couldn&#8217;t be more different. But then again, I can access both using identical interfaces:</p>
<pre class="brush: csharp">
// Linq is understood by both, so you could use the lines in both:
var u = (from Note n in container
         where n.Text == null select n).ToList();
var v = session.Query&lt;Tag&gt;().Where(p =&gt; p.Name != null);
// Store an object graph to Mongo using NoRM:
session.Add(testNote);
// Store an object graph to db4o:
container.Store(testNote);
</pre>
<p>Don&#8217;t be fooled &#8211; although these lines could all be used with MongoDB or db4o and all of them could even be used with the very same classes, they are still fundamentally different in behavior. Also, for anything but the most simple problems, <strong>you can&#8217;t just persist the same domain models</strong>.</p>
<h2>What is a document now?</h2>
<p>A document is not just an unstructured piece of data. It&#8217;s not a BLOB. Instead, an instance of a class, <strong>plus all it refers to</strong>, could be a document:</p>
<pre class="brush: csharp">
class UniqueIdObject
{
    public Guid Id { get; private set; }
    public UniqueIdObject() { Id = Guid.NewGuid(); }
}

class Report : UniqueIdObject
{
    public Report() : base() { Tags = new List&lt;Tag&gt;(); }
    public string Text { get; set; }
    public List&lt;Tag&gt; Tags { get; set; }
}

class Tag : UniqueIdObject
{
    public string Name { get; set; }
}
</pre>
<p>Now we might want to store a note in the database, and the code needed is just</p>
<pre class="brush: csharp">
using (NoRMSession session = new NoRMSession())
{
    Report newReport = new Report() { Text = &quot;Hello World, MongoDB!&quot; };
    newReport.Tags.Add(new Tag() { Name = &quot;Tag 1&quot; });
    newReport.Tags.Add(new Tag() { Name = &quot;Tag 2&quot; });
    session.Add(newReport);
}
</pre>
<p>That&#8217;s it! Wow! Of course, we haven&#8217;t taken care of indexation and stuff and since MongoDB is schemaless (or better, has a dynamic schema) we need to do that in code. But still, this is essentially all you need.</p>
<p>The important thing now is: What happens to those little `Tags` we deliberately put into a separate class? Now the mapper hides a bit of truth from us, because MongoDB works on so-called &#8220;Collections&#8221;. <code>session.Add(newReport)</code> will be <code>session.Add&lt;Report&gt;(newReport)</code>, which will in turn put the <code>newReport</code> object <strong>into the Report-Collection!</strong> So the object graph, as it is, will be serialized into the Report collection, <em>including</em> our little Tag objects!</p>
<p>Each item with an orange border is an &#8216;atomic&#8217; item in its respective data store:</p>
<div id="attachment_242" class="wp-caption alignleft" style="width: 310px"><a href="http://www.emphess.net/wp-content/uploads/2010/05/db4o-graph.png"><img src="http://www.emphess.net/wp-content/uploads/2010/05/db4o-graph-300x184.png" alt="" title="db4o-graph" width="300" height="184" class="size-medium wp-image-242" /></a><p class="wp-caption-text">db4o serialized graph</p></div>
<p><div id="attachment_241" class="wp-caption alignleft" style="width: 310px"><a href="http://www.emphess.net/wp-content/uploads/2010/05/mongo.png"><img src="http://www.emphess.net/wp-content/uploads/2010/05/mongo-300x200.png" alt="" title="mongo" width="300" height="200" class="alignright size-medium wp-image-241" /></a><p class="wp-caption-text">mongo serialized document</p></div><br />
</p>
<div style="clear: both;"></div>
<p>Let&#8217;s naively try to fetch all tags:</p>
<pre class="brush: csharp">
var v = session.Query&lt;Tag&gt;().Where(p =&gt; p.Name != null);
</pre>
<p>This does not work, <code>v</code> is <code>null</code> because there is no tag collection! Instead, the tag lists are <strong>part of the reports</strong> we put into the <code>Report</code> collection. Note that this would work in db4o, because db4o will store references as references, while &#8216;documents&#8217; store the contained data instead of references. This is beautifully simple, but it&#8217;s also very different from what you might expect and it has lots of implications for your object structure.</p>
<h2>Thoroughly think through your schemaless schema</h2>
<p>MongoDB is made for <em>scalability and simplicity</em>, so it does not care for our foolish approach to fetch tags directly. There are ways to access that data directly, however. We could use a deep-graph query or write a javascript Map/Reduce instruction, but that is a bit out of scope right now. What&#8217;s more important is that it calls for <strong>changes to our domain model objects</strong>: If we really want to store a reference, we need to do so manually, in ye olde sql-way, by storing the associated Id instead of the object. Of course, that makes deserialization a bit more complicated because the object we now retrieve from the database aren&#8217;t ready-to-use as they come.</p>
<p>However, automating that process will induce several complications, among them the need to <strong>handle cyclic references</strong>, a concept for fetching or activating objects on-the-fly, called <strong>Transparent Activation</strong> in the db4o world and making sure we&#8217;re not inducing a massive performance hit along the way.</p>
<p>Also, updating objects can be painful. Suppose we stored a list of <code>Reports</code> for each user. Now we might want to put the list of reports directly into the user object, <strong>or</strong> store a list of <code>ReportIds</code> for each users and put the Reports into their very own ReportCollection. As usual, <strong>there is no silver bullet</strong>, so this decision depends on the specific needs of the application, but whatever decision we take will not be visible to users of the resulting objects. In fact, it leads to some unwanted <strong>strong coupling</strong>:</p>
<pre class="brush: csharp">
class ReportService
{
  private NoRMSession _session;

  // ...
  public void UpdateReportDetail()
  {
    this.ReportDetailXY = ComplicatedCalculation();
    this.LastChanged = DateTime.UtcNow;

    // If the reports are in their very own Report Collection, this
    // is fine. However, if they are contained as lists in the user
    // who owns them, we&#039;re in trouble and this will fail!
    _session.Update(this);
  }
}
</pre>
<p>This might not be a big problem for <strong>really small applications</strong>, and if you really need performance (why else would you choose a NoSQL system?) you have to fine-tune your objects anyways. Still, I have the feeling that there is some space for improvement here, and a <strong>basic</strong> wrapper could help in overcoming some of the issues raised. Some basic ideas on how to approach this will follow shortly.</p>
<h2>Wrapping it up</h2>
<p>Obviously, I&#8217;m comparing Apples and Oranges here: db4o is made to <strong>make persistence easier</strong>, especially with complex domain model objects. db4o, being an <strong>object database</strong>, behaves exactly the way you&#8217;d expect objects under serialization to behave, but that makes it quite complex. MongoDB is focused on <strong>simplicity and scalability</strong>. Through the document concept, you gain simplicity on the database, administration and wrapper (driver)-side, but you have to struggle with a slight <strong>impedance mismatch</strong> in code, especially against Linq, again.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=The+Object-Document+Mismatch%3A+MongoDB+and+db4o+with+Linq+http%3A%2F%2Femphess.net%2F%3Fp%3D232" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/&amp;title=The+Object-Document+Mismatch%3A+MongoDB+and+db4o+with+Linq" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/&amp;title=The+Object-Document+Mismatch%3A+MongoDB+and+db4o+with+Linq" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/&amp;t=The+Object-Document+Mismatch%3A+MongoDB+and+db4o+with+Linq" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/05/05/the-object-document-mismatch-mongodb-and-db4o-with-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My db4o Wishlist</title>
		<link>http://www.emphess.net/2010/04/14/my-db4o-wishlist/</link>
		<comments>http://www.emphess.net/2010/04/14/my-db4o-wishlist/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 22:30:18 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[db4o]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[Object Database]]></category>
		<category><![CDATA[OODBMS]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=168</guid>
		<description><![CDATA[After finding that db4o did not screw up in our projects, I dug a bit through their issue tracker, which is a very important resource you should definitely check out if you&#8217;re working with db4o! Just to get that straight: I&#8217;m an avid db4o user and really love it. These issues are not critical and [...]]]></description>
			<content:encoded><![CDATA[<p>After finding that <a href="http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/">db4o did not screw up</a> in our projects, I dug a bit through <a href="http://tracker.db4o.com/secure/Dashboard.jspa">their issue tracker</a>, which is a very important resource you should definitely check out if you&#8217;re working with db4o!</p>
<p>Just to get that straight: I&#8217;m an avid db4o user and really love it. These issues are not critical and they don&#8217;t stop me from using or evangelizing db4o. However, I think there is some lack of awareness of some issues.</p>
<p>Also, I&#8217;d like to spawn some discussion about the issues below. Unfortunately, due to their changes to the forum system, most of the original discussions on the <a href="http://developer.db4o.com/Forums.aspx">db4o forum</a> are hard to find or possibly lost. You may want to <em>vote on the issues you deem most pressing</em>, which you can easily do in their issue tracker! I&#8217;m very interested in what you think about this little selection.</p>
<h2>Selected Issues</h2>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1133">Don&#8217;t run SODA when no more constraints are present</a><br />
I <a href="http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/">blogged about this already</a>, because you experience this in very common scenarios, namely whenever you query a small subset of a larger candidate set. For example, consider selecting the last 50 posts on a blog/qa-site/etc. What will happen is that db4o runs the BTREE query for the sort operation (blazing), <em>then hydrates (?) all objects</em>, the returns the first 50 of them and throws away the rest. Thing is that there is no need to further inspect the items, and activating all them is basically a linear operation. Thus, this common type of query currently runs in <em>O(n)</em> instead of <em>O(log n)</em> which is an incredibly dramatic difference.</p>
<p><span id="more-168"></span></p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1899">LINQ-Implementation is not &#8216;thread&#8217;-safe</a><br />
A very <a href="http://blog.stevensanderson.com/2007/11/29/linq-to-sql-the-multi-tier-story/">similar issue has been on LINQ-to-SQL&#8217;s todo list some time ago</a>.<br />
I&#8217;m not sure whether this is so much the typical use case. For the db4o case, it teaches us two things right now:</p>
<ul>
<li>Container reuse is non-trivial and should be approached with extreme care. You don&#8217;t want to run into this kind of byzantine error in a live app.</li>
<li>The object identity problem is similar in both Object-Relational Mapping and OODBMS</li>
</ul>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-191">Scalable server architecture: multiple readers against the same file, transactional files</a><br />
This sounds daunting, and it&#8217;s probably a huge one, as you can see from its age. I also believe this might be politically challenging, because this moves into the direction of <a href="http://www.versant.com">Versant&#8217;s</a> large-scale object database. However, there is a lot of movement into that direction from the user-side it seems &#8211; people are asking for features of this kind more and more lately, largely due to the ultra-cool LINQ integration db4o has. I suppose I&#8217;d be wise to focus on this kind of scenario as it could really become the preferred way of writing web applications: it&#8217;s extremely agile, supports rapid development, is flexible in that the same (LINQ) code could be used for different persistence layers if that should ever be needed and leads to clean, compile-time checked, type-safe code.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-236">Sanitize reflector design &#8211; remove core dependencies on generic reflector</a><br />
Being able to get rid of the generic reflector seems important, I&#8217;m already building my own code for this. Here we have conflicting requirements: The GenericReflector makes db4o very easy to use and may help beginners. It is also required in client-server scenarios where the server doesn&#8217;t have the necessary model dlls, but for most applications I think you should try to avoid it. Storing data in a generic manner is slow and requires a lot more space, making it highly inefficient.</p>
<p>Current attack vector: <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9635/afv/topic/Default.aspx">Throw a Listener on the object created event</a> on the server and make sure the server knows the type.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1905">Allow immediate TCP port reuse</a><br />
When opening a server, the TCP port will be blocked in case the server crashes, the app is terminated, etc. Since that might happen quite often when you use the &#8216;integrated server&#8217; where the server is actually created in your web application, a restart of the web application will fail because the TCP port is blocked. In a client-server scenario, on the other hand, a simple restart wouldn&#8217;t be possible because you need to assign a new port to clients or wait 6 minutes. This should be fairly simple, but I don&#8217;t know if that comes with any side-effects.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-113">Fast Collections</a><br />
This is a huge one. The cool thing is that this could allow much more complicated queries to be executed in reasonable timeframes. However, I&#8217;m a bit worried about <a href="http://tracker.db4o.com/browse/COR-644">the issue &#8220;FastCollections: Inside BTree List implementation&#8221;</a>, because that sounds really important, but is in state &#8220;Won&#8217;t fix&#8221;.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-478">Locking</a><br />
Optimistic locking would be a nice-to-have thingie, but you do this yourself rather easy I think.</p>
<p>&raquo; <a href="http://tracker.db4o.com/browse/COR-1772">A new object is stored upon value type updates</a><br />
This is rated critical, so it&#8217;s not an item for a &#8220;wishlist&#8221;. I&#8217;m not sure if I understand its implications and I rarely use value types apart from Guids, and updating Guids is pointless &#8211; still a db4o user should probably know this and keep this in mind, so I felt it should go here &#9760;.</p>
<h2>db4o Configuration</h2>
<p>This one is not really in the issue tracker as a single item, and it&#8217;s more of a general remark. <em>One of the rather messy things in db4o is configuration</em>. Even with the <a href="http://programing-fun.blogspot.com/2008/10/changes-in-db4o-configuration.html">new configuration interface</a>, there is quite a bit of confusion among users. The reason, in my eyes, is mostly a combination of incomplete documentation and unexpected behaviour. Examples:</p>
<ul>
<li>The indexation setting for fields is the only configuration setting that is persistent. Everything else, including unique constraints, needs to be re-set when (or &ndash; more precisely &ndash; <em>before</em>) opening the <code>ObjectContainer</code>.</li>
<li>Applying an option to a field that doesn&#8217;t exist will not trigger a warning or an <code>Exception</code></li>
<li>Some settings simply won&#8217;t have any effect when you perform them after opening the <code>ObjectContainer</code>, but they do not warn you.</li>
<li>Certain settings <strong>must</strong> be applied on the server, a few <strong>must</strong> be applied on the client and with some &#8230; well, you just set them on both just to make sure. Here, db4o does throw exceptions, however!</li>
<li>Several options need to be set before <em>creating</em> the object container (e.g. string encoding) and cannot be reset afterwards, again being completely silent about the ineffectiveness of the respective settings.</li>
<li>Some settings, such as field-based cascade-on-activate, <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9783/afv/topic/Default.aspx">simply don&#8217;t seem to work at all</a></li>
</ul>
<p>This leads to lots and lots of confusion. Most importantly, it is often hard to determine whether a certain setting was successfully applied, or not. Also, some defaults are unexpected:</p>
<ul>
<li>Default <code>ActivationDepth</code> is (completely random) 5. Why not 8? Or 2? This troubles beginners a lot. Either set it to infinity, or to zero. Everything else feels just random. You can still include a line <code>ActivationDepth = 5;</code> in beginner&#8217;s samples, thereby showing them that the setting is there and that they need to be aware of it.</li>
<li>Default string encoding seems to be <code>UTF-16</code> or <code>UCS-2</code>, probably the most useless encodings around, despite the Windows Kernel working with it. <code>UTF-8</code> would come in as a reasonable default, but with <code>UTF-16</code> half of your database is probably zeros, because even in non-english environments, there is still a lot of mostly ASCII-data to be stored (such as URLs, Email addresses, base64 encoded information, SHA-hashes, etc.). Also many languages have non-ASCII characters only sparingly, German being one example.</li>
</ul>
<p>I think it&#8217;d be really cool if the configuration interface was a little more explicit and would throw Exceptions instead of silently ignoring requests that cannot be fulfilled.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=My+db4o+Wishlist+http%3A%2F%2Femphess.net%2F%3Fp%3D168" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;title=My+db4o+Wishlist" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;title=My+db4o+Wishlist" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/04/14/my-db4o-wishlist/&amp;t=My+db4o+Wishlist" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/04/14/my-db4o-wishlist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NoSQL Approaches: Trying to use db4o in the Real World</title>
		<link>http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/</link>
		<comments>http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 22:14:38 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[db4o]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Startup]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=138</guid>
		<description><![CDATA[We&#8217;ve been working a lot on db4o related and db4o based projects lately, and close to completion of the first and most simple product, we really hit a few roadblocks. UPDATE: Just after releasing this article, I found the bug in our code. It&#8217;s not db4o&#8217;s fault after all&#8230; Motivation One thing up front: We [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been working a lot on <a href="http://www.db4o.com">db4o</a> related and db4o based projects lately, and close to completion of the first and most simple product, we really hit a few roadblocks.<br />
<strong>UPDATE: Just after releasing this article, I found the bug in our code. It&#8217;s not db4o&#8217;s fault after all&#8230;</strong></p>
<h2>Motivation</h2>
<p>One thing up front: We don&#8217;t need an <a href="http://en.wikipedia.org/wiki/Object_database">object database</a> for the simple tools we currently build, but we felt it was a good idea to get some acquaintance with the technology, because we will certainly need it for our (stealth) startup &#8220;pactas&#8221; soon. In pactas, the data structure is really complicated (with a fancy class hierarchy) and it probably will change very frequently.</p>
<p>Also, since I am such a big fan of reusability, we really develop a web engine &#8211; a framework that allows us to reuse a lot of the code for different projects and make sure most of our code has been tested thoroughly in the field. This proves to be a significant design decision when it comes to data modeling, and while I&#8217;m very happy with the decision, it certainly makes development harder.</p>
<h2>The Problem</h2>
<p>So, in time with the release of our simple <a href="http://www.backlink-tracker.net">backlink tracker</a>, one of our development database files started to show strange behaviour &#8211; a certain query (via LINQ) would not order objects anymore &#8211; the <code>orderby</code>-clause seemingly was completely ignored. Our live server even came up with an &#8220;Invalid DateTimeKind specified&#8221; exception when trying to perform the query! What&#8217;s worse: The problem kept occurring from time to time, but it was not reproducible! Byzantine errors are clearly my favourite&#8230; </p>
<p>We thought the issue might be related to the current development/unstable versions of db4o that we were using (7.12 and 7.13). Using the stable version of db4o (7.4) proved difficult, because the old LINQ provider falls back to LINQ to Objects very often, which requires to fetch all objects in question from the database &#8211; that is very, very slow for a lot of objects, so we had to abandon that. We clearly wanted to stick to LINQ for a number of reasons (compile-time checking, readability, reusability).</p>
<p>Obviously the problem is related to the <code>orderby</code> operation on <code>DateTime</code> fields. I tried to modify the query, removed grouping because I feared it might be unstable (<em>warning</em>: the <em>sort</em> operation is, in fact, unstable! Unstable grouping would be useless, but the grouping is stable so that&#8217;s fine), even debugged the db4o code, but I couldn&#8217;t find any problem in there. Since the code is rather complex and that was the first time I took a look at it, I was happy to find some of the relevant code at all. <font style="text-decoration: line-through;">Somewhere in the deeps of it, something screwed up.</font> I didn&#8217;t want to spend too much time on that since I had to chew some particle physics on the side. </p>
<h2>Solutions?</h2>
<p>At the time of writing this (in fact, yesterday) I had something like a hotfix, but it turned out it&#8217;s completely nonsense &#8211; it worked around our internal bug in a very peculiar way. No more, no less.</p>
<p>When talking about this, somebody mentioned that it wasn&#8217;t such a good idea to use <code>DateTime</code> at all, and we should store the ticks instead. That lead to two long discussions with my co-ed Christian. We concluded: First, the power of object databases is that they do not force you to hack around and find different representations for your data (which raises the bar for object databases). The one big shortcoming of SQL is that it forces you to find a second, equally good, but different representation of your data and you need to translate between these representations all the time. You need to synchronize them. And you lose a lot of fancy features (such as lists, generics, inheritance, etc.) on the way.</p>
<p>Secondly, Christian suggested that object databases suffer from <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html">leaky abstractions</a> badly, in that they break encapsulation in a way that leaks out a hell of a lot of implementation details. As Joel puts it: &#8220;All non-trivial abstractions, to some degree, are leaky.&#8221; The point is: <font style="text-decoration: strikethrough">With the error we&#8217;re currently encountering, it&#8217;s becoming a <em>real problem</em>. This is not an <a href="http://www.codinghorror.com/blog/2009/06/all-abstractions-are-failed-abstractions.html">imperfect piece of architecture</a>, it&#8217;s an exception in a database query. It kills the app dead! Boom!</font></p>
<p>In order to get activation [depth] straight, db4o needs to know how .NET&#8217;s containers work internally &#8211; that is clearly a detail that should be hidden, but db4o knows about it. db4o also takes care of that, but it leads to some messy issues. There is special code in db4o that handles containers, non-trivial objects such as <code>strings</code>, <code>DateTime</code> (which are non-trivial because they use 62 bits for the actual ticks and 2 bits for the <a href="http://msdn.microsoft.com/en-us/library/shx7s921.aspx">DateTimeKind</a>) and Lists. This is an implementation detail of the .NET framework, and it might change over time. There&#8217;s <a href="http://tracker.db4o.com/browse/COR-1582">been a bug with <code>Map</code></a>, and I&#8217;m almost sure there is a bug with <code>DateTime</code>, too. Don&#8217;t get me wrong: The fact that <em>some kind of mapping</em> is needed is a somewhat generic (if not <em>the</em>) problem of serialization, it&#8217;s not really db4o-specific, and cannot be eliminated. In Hibernate, there is also a lot of code that handles the mapping of lists and the like but it doesn&#8217;t rely on implementation detail, thus it&#8217;s not (as) leaky.</p>
<h2>Back to SQL?</h2>
<p>Here&#8217;s the thing: I&#8217;d be beneficial to have a storage that is <em>independent of the actual implementation on top</em>, because it decouples the data store from the application which is <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9847/afv/topic/Default.aspx">not what db4o does</a>. But wait, that is exactly what SQL is, right? Indeed: SQL forces you to map (or to cut down) your stuff to it&#8217;s internal features. A list becomes a foreign key on the other table, but that doesn&#8217;t play well with derived types, generics, etc&#8230; This is tricky as we all know, and <a href="http://www.ohloh.net/p/nhibernate/analyses/latest">you need lots of code to do that</a>. </p>
<p>Worse, SQL forces you do that mapping for everything, including your own classes, and it demands a schema for every type of object &#8211; this is not what I want. I&#8217;d like to see a set of base objects in an object database which are natively understood by the DB. These objects can be mapped from and to by a layer which may be part of the db, or can be added manually if you need something very special. Still, it should allow to store your object in the database with all it&#8217;s magic, only that known objects will be translated, e.g. a <code>DateTime</code> will be stored as <code>long Ticks</code> and a <code>DateTimeKind</code> flag separated, making comparison operations easier (note that the comparison only works on the ticks: Whether the time is local or UTC is not considered by .NET in comparisons). Lists will be unfolded into an internal tree representation if indexed, so they become much easier to cope with for the database. That would also make <a href="http://www.gamlor.info/wordpress/?p=1069">managing m:n relations</a> easier, since they could then be viewed as bilateral relationships &#8211; something you often need. Right now, they&#8217;re unilateral, thereby requiring some additional management on your behalf.</p>
<p>Migrating to SQL is clearly an option for this product, since data couldn&#8217;t fit SQL any better, but that doesn&#8217;t solve the issue for our pactas project, where we certainly will need schema-less data, complex object hierarchies, etc.</p>
<p>However, there are a few issues that <font style="text-decoration: line-through;">remain unresolved as of now and they do qualify as show stoppers</font> :</p>
<ul>
<li style="text-decoration: line-through;">There&#8217;s an irreproducible bug that potentially wrecks the db</li>
<li>There&#8217;s a <a href="http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/">nasty performance issue with larger amounts of data</a></li>
</ul>
<h2>Alternatives</h2>
<p>I&#8217;m quite dissatisfied that we <font style="text-decoration: line-through;">have to abandon db4o at this stage</font>, because I believe it&#8217;s the best kind of serialization I&#8217;ve ever experienced. It&#8217;s <a href="http://blog.wekeroad.com/2010/02/06/nosql-a-practical-approach-part-1">perfectly simple</a>, it&#8217;s fast and most importantly, code-centric. If reusability is a concern, having the database structure and/or the ORM mapper dictate the objects is a major pain.</p>
<p><a href="http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework">Entity Framework 4 (EF4)</a> promises to handle this a lot better through <a href="http://blogs.msdn.com/adonet/archive/2009/05/12/sneak-preview-model-first-in-the-entity-framework-4-0.aspx">&#8220;Model First&#8221;</a> and <a href="http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspx">&#8220;Code Only&#8221;</a>, but I am still a bit afraid of EF because it doesn&#8217;t appear to be anything near lightweight and we will need schemaless storage for our future products anyways.</p>
<p><a href="http://www.versant.com">Versant</a>, which bought db4o some time ago also offers its large-scale object database, which seems to suit large web-applications a lot better. First, it&#8217;s certainly made for huge amounts of data (unlike db4o, which comes from an embedded background and <a href="http://www.sdtimes.com/link/33117">is aimed at database sizes in the low GB area</a>, but <a href="https://developer.db4o.com/Documentation/Reference/db4o-7.4/java/reference/html/reference/tuning/performance_hints/increasing_the_maximum_database_file_size.html">supports up to 254 GB per file</a>) and <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9855/afv/topic/Default.aspx">handles multi-threading better</a>. Also, since db4o <a href="http://www.itwire.com/sponsored-announcements/38149-versant-expands-db4o-open-source-licensin">now moved to v3 of the GPL</a>, it may not be freely usable in non-open source web applications anymore, so both solutions now have a price tag.</p>
<p>There is also an <a href="http://www.versant.com/en_US/solutions/oem_program/">ISV/OEM empowerment program</a> for Versant&#8217;s Object Database, which seems to make it affordable, but I haven&#8217;t looked at it in detail yet. Over the next weeks, I will have to evaluate a few of those other NoSQL solutions such as <a href="http://cassandra.apache.org/">Cassandra</a> and <a href="www.mongodb.org/">MongoDB</a>, just to name two totally different options. </p>
<h2>Aftermath</h2>
<p>So what was the issue, after all? db4o did not screw up, we did: Take a blend of local and UTC time based on a completely random criterion, add two spoons of daylight savings time changes, add some misconfigured timezone on the server, bake for two weeks at 500 &deg; C and pling! You got yourself some really strange issue cake. Lessons learned:</p>
<ul>
<li>Debugging issue with object databases is harder than with RDBMS because the information is not chopped up.</li>
<li>Do code reviews. Do code reviews.</li>
<li>There aren&#8217;t too many alternatives to db4o, after all</li>
<li>With the elaborated architecture and code-centric design we currently have, going back to SQL is a huge pain, and we won&#8217;t do it</li>
</ul>
<p>All serialization is painful.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=NoSQL+Approaches%3A+Trying+to+use+db4o+in+the+Real+World+http%3A%2F%2Femphess.net%2F%3Fp%3D138" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/&amp;title=NoSQL+Approaches%3A+Trying+to+use+db4o+in+the+Real+World" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/&amp;title=NoSQL+Approaches%3A+Trying+to+use+db4o+in+the+Real+World" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/&amp;t=NoSQL+Approaches%3A+Trying+to+use+db4o+in+the+Real+World" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/04/12/nosql-approaches-trying-to-use-db4o-in-the-real-world/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>db4o Queries on Large Datasets and a bit of Linq</title>
		<link>http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/</link>
		<comments>http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 12:26:49 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[db4o]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=123</guid>
		<description><![CDATA[My last small note on db4o performance will soon be outdated &#8211; fortunately. Newer releases of db4o will no longer rely on Cecil to perform reflection, thereby speeding up db4o linq queries &#8211; However, make sure you have Mono.Reflection.dll in your app! Also there are some restrictions when it comes to the compact framework and [...]]]></description>
			<content:encoded><![CDATA[<p>My last small note on db4o performance <a href="http://developer.db4o.com/Forums/tabid/98/aff/37/aft/9716/afv/topic/Default.aspx">will soon be outdated</a> &#8211; fortunately. Newer releases of db4o will no longer rely on Cecil to perform reflection, thereby speeding up db4o linq queries &#8211; <strong>However, make sure you have Mono.Reflection.dll in your app!</strong> Also there are some restrictions when it comes to the compact framework and native queries (which still need Cecil), so you&#8217;d best make sure to <a href="http://developer.db4o.com/Blogs/Product/tabid/167/archive/month/date/2010-02-28/Default.aspx" target="_blank">read this official db4o announcement</a>.</p>
<p>Talking about speed and performance, I just came across an issue that was also discussed in db4o forums very recently: Sort operations on large datasets.<br />
Note: This has nothing to do with linq or linq to db4o, it&#8217;s just the same for SODA queries.</p>
<p>Let&#8217;s take a very common example: Find some most recent items, for example most recent blog/forum posts or some other &#8216;top list&#8217; on a very large amount of entries N:</p>
<pre class="brush: csharp">
        var mostRecentPosts = (from Posts o
              in ObjectContainer
              orderby o.Created descending
              select o).Take(100).ToList();
</pre>
<p>This query will be really really slow on a large amount of objects. Why? Essentially, the BTREE operation is very fast as it should be, but unfortunately db4o will invoke its SODA system on each of the objects, even if they are already outruled by the BTREE operation. </p>
<p>See <a href="http://developer.db4o.com/Forums/tabid/98/aff/4/aft/9751/afv/topic/afpgj/1/Default.aspx#27735">this discussion on the db4o forum</a> and <a href="http://tracker.db4o.com/browse/COR-1133">the associated Jira-bug</a>.</p>
<p>This is somewhat sad, because a query on a previously filtered set of items is blazing, about 100x faster:</p>
<pre class="brush: csharp">
        var mostRecentPosts = (from Posts o
              in ObjectContainer
              where o.Created &gt; yesterday
              orderby o.Created descending
              select o).Take(100).ToList();
</pre>
<p>The latter operation plays roughly in the same league as SQL Server (don&#8217;t flame me &#8211; performance comparisons and profiling is really complicated and there is a zillion of factors that influence it, I know. That&#8217;s why I say &#8216;roughly the same league for this query&#8217; and I&#8217;m talking about default setups). </p>
<p>This is a somewhat unfortunate situation, because it produces slow queries for many typical applications &#8211; unless you have a strong where clause that cuts down N from millions to hundreds. If you&#8217;re interested in seeing this issue fixed, head over to their <a href="http://tracker.db4o.com/browse/COR-1133">issue tracker and vote for the issue to be fixed</a>! Thanks!</p>
<p>I&#8217;ll be posting a bit more on db4o over the next few days I hope.</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=db4o+Queries+on+Large+Datasets+and+a+bit+of+Linq+http%3A%2F%2Femphess.net%2F%3Fp%3D123" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/&amp;title=db4o+Queries+on+Large+Datasets+and+a+bit+of+Linq" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/&amp;title=db4o+Queries+on+Large+Datasets+and+a+bit+of+Linq" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/&amp;t=db4o+Queries+on+Large+Datasets+and+a+bit+of+Linq" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2010/03/16/db4o-queries-on-large-datasets-and-a-bit-of-linq/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DependencyProperty Serialization Part II</title>
		<link>http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/</link>
		<comments>http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 19:06:09 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Dependency Property]]></category>
		<category><![CDATA[ISerializationSurrogate]]></category>
		<category><![CDATA[Serialization]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=43</guid>
		<description><![CDATA[First off, my apologies for not posting the second part earlier. I have had a lot to do in the past Months&#8230; Part II of the article will show how a SerializationSurrogate works and explore wheter we can use it for generic de-serialization of DependencyProperties. Also, in this article I provide full source code for [...]]]></description>
			<content:encoded><![CDATA[<p>First off, my apologies for not posting the second part earlier. I have had a lot to do in the past Months&#8230;</p>
<p>Part II of the article will show how a <code>SerializationSurrogate</code> works and explore wheter we can use it for generic de-serialization of <code>DependencyProperties</code>. Also, in this article I provide full source code for both parts of the article.</p>
<p>UPDATE: A much better version of this article can now be found at the CodeProject: <a href="http://www.codeproject.com/KB/cs/BPBOSerialization.aspx">DependencyProperty Serialization for Business Objects </a></p>
<p>Alternatively, directly get the source code here: <a href="http://www.emphess.net/wp-content/uploads/2009/03/bpboserialization1.zip">http://www.emphess.net/wp-content/uploads/2009/03/bpboserialization1.zip</a></p>
<p><span id="more-43"></span></p>
<p>Well, let&#8217;s get started:</p>
<h2>ISerializationSurrogate</h2>
<p>This interface is designed as a stand-in for your class upon serialization and de-serialization.</p>
<p>It is quite simple and contains only two methods:<br />
<code><br />
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)<br />
</code><br />
and<br />
<code><br />
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)<br />
</code></p>
<p>This is quite interesting, since there is an explanation on MSDN why they chose <em>not</em> to provide a <code>SetObjectData()</code> method for the <code>ISerializable</code> interface, so this makes quite a difference.</p>
<h2>Surrogate Serialization</h2>
<p>For serialization, we use almost the same code we used in part I, with a few modifications only:</p>
<pre class="brush: csharp">
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
{
    PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(obj.GetType(),
            new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.SetValues |
                                                          PropertyFilterOptions.UnsetValues |
                                                          PropertyFilterOptions.Valid ) });

    List&lt;FieldInfo&gt; fieldInformation = ReflectionHelper.GetFieldInformation(obj.GetType());

    foreach (FieldInfo fiRover in fieldInformation)
    {
        object[] attribs = fiRover.GetCustomAttributes(typeof(NonSerializedAttribute), false);

        if (attribs.Length &gt; 0)
            continue; // Don&#039;t serialize this

        info.AddValue(fiRover.Name, fiRover.GetValue(obj));
    }

    foreach (PropertyDescriptor propertyDescriptor in descriptors)
    {
        SerializeProperty(obj, info, propertyDescriptor);
    }
}
</pre>
<p>(Please note that I clean the code up a little, in the source download there is a lot of debugging output, etc.)</p>
<h2>Surrogate De-Serialization</h2>
<p>Now, it seems as if an implementation of <code>ISerializationSurrogate</code> might do the job and help us to circumvent the necessity to provide boring constructors through the <code>SetObjectData()</code> method. So let&#8217;s give it a try by basically using the deserialization code from part I:</p>
<pre class="brush: csharp">
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
{
    Type thisType = obj.GetType();
    DependencyObject depObj = obj as DependencyObject;

    // De-Serialize Fields
    List&lt;FieldInfo&gt; fieldInformation = ReflectionHelper.GetFieldInformation(thisType);

    foreach (FieldInfo fiRover in fieldInformation)
    {
        object[] attribs = fiRover.GetCustomAttributes(typeof(NonSerializedAttribute), false);

        if (attribs.Length &gt; 0)
            continue; // Don&#039;t deserialize this

        fiRover.SetValue(obj, info.GetValue(fiRover.Name, fiRover.FieldType));
    }

    // De-Serialize DependencyProperties
    PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(thisType,
            new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.SetValues |
                                                          PropertyFilterOptions.UnsetValues |
                                                          PropertyFilterOptions.Valid ) });

    // Try to use a mapping to set all DP values deferred. This will actually just
    // postpone the Exception
    List&lt;DependencyValueMap&gt; mappingList = new List&lt;DependencyValueMap&gt;();

    foreach (PropertyDescriptor propertyDescriptor in descriptors)
    {
        if (propertyDescriptor.Attributes[typeof(NonSerializedAttribute)] == null)
        {
            DependencyProperty dp = DependencyPropertyHelper.FindDependencyProperty(obj, propertyDescriptor.Name);

            if (null != dp)
            {
                mappingList.Add(new DependencyValueMap(dp, obj as DependencyObject, info.GetValue(propertyDescriptor.Name, propertyDescriptor.PropertyType)));
            }
            else
            {
                throw new SerializationException(String.Format(@&quot;Failed to deserialize property &#039;{0}&#039; on object of type &#039;{1}&#039;.
Property could not be found. Version Conflict?&quot;, propertyDescriptor.Name, thisType));
            }
        }
    }

    foreach (DependencyValueMap dvRover in mappingList)
    {
        // This call will cause an InvalidOperationException:
        depObj.SetValue(dvRover.dp, dvRover.value);
    }

    return null;
}
</pre>
<p>Now, unfortunately, we cannot set the values of these DependencyProperties. The <code>SetValue() </code> method in <code>DependencyObject</code> will throw the oh-so-magic <code>InvalidOperationException</code>. I haven&#8217;t been able to find a way to go around this.</p>
<h2>Summing it up</h2>
<p>Well, that&#8217;s it basically. Where are we now?</p>
<ul>
<li>It is possible to use DependencyProperties for business objects and serialize and deserialize them.</li>
<li>A reflection-based base class &#8220;SerializableDependencyProperty&#8221; does the job, as long as you stick to the naming convention and implement the deserialization constructor in all derived classes</li>
<li>Circumventing the explicit deserialization constructor seems impossible due to limitations of the DependencyObject base class</li>
</ul>
<h2>The Source</h2>
<p>The sample solutions contains two projects:<br />
WPFDependencyPropertySerialization shows how the serialization of part I can be accomplished.<br />
WPFDependencyPropertySerializationError shows the extension using an ISerializationSurrogate and, as mentioned before, will lead to an Exception &#8230; which will not be caught so you can really feel it rumbling:<br />
&#8220;Current local value enumeration is outdated because one or more local values have been set since its creation.&#8221;</p>
<p>You can download the source at <a href="http://www.emphess.net/wp-content/uploads/2009/03/bpboserialization1.zip">http://www.emphess.net/wp-content/uploads/2009/03/bpboserialization1.zip</a></p>
<p>Have Fun!</p>
<h2>A post scriptum on DependencyProperties for business entities</h2>
<p>The project I&#8217;m currently working on comes with a very complex data structure. It consists of a set of trees which can be connected in various different ways. We also have to account for circular dependencies between these objects. The user can create and modify all these different types of connections.<br />
Moreover, the architecture of the application is highly sophisticated and is based on Microsoft&#8217;s composite application guidance. A lot of modules interact with each other, each having their own data, similar to a ViewModel yet managed by a Presenter. What sounds a little messy has been proven to be the best solution in a number of discussions.<br />
These business entities are based on DependencyProperties and a lot of crucial features depend on the functionality provided by the DependencyProperties. It works well, though I should mention that I did not use a number of DependencyProperty features in the first place. For example, coercion and validation coupled with automated de-serialization might lead into trouble, so keep this in mind should you ever intend to go down the path&#8230;</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=DependencyProperty+Serialization+Part+II+http%3A%2F%2Femphess.net%2F%3Fp%3D43" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/&amp;title=DependencyProperty+Serialization+Part+II" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/&amp;title=DependencyProperty+Serialization+Part+II" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/&amp;t=DependencyProperty+Serialization+Part+II" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2009/03/04/dependencyproperty-serialization-part-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ICommand.CanExecute() and NullReferenceException</title>
		<link>http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/</link>
		<comments>http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 17:12:57 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Custom Command]]></category>
		<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[ICommand]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=31</guid>
		<description><![CDATA[Have you ever tried to call ICommand.CanExecute()? It actually works fine, but only if you are not as naive as I am&#8230; Simply calling it without the proper know-how might result in a NullReferenceException, so what you should read is how to implement ICommandSource. See MSDN: How To: Implement ICommandSource MSDN: Implement ICommandSource Sample. Not [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever tried to call <code>ICommand.CanExecute()</code>? It actually works fine, but only if you are not as naive as I am&#8230; Simply calling it without the proper know-how might result in a <code>NullReferenceException</code>, so what you should read is how to implement <code>ICommandSource</code>. See</p>
<p><a href="http://msdn2.microsoft.com/en-us/library/ms748978.aspx">MSDN: How To: Implement ICommandSource</a><br />
<a href="http://msdn2.microsoft.com/en-us/library/ms771361.aspx">MSDN: Implement ICommandSource Sample</a>.</p>
<p>Not a big thing, but since google didn&#8217;t show anything for &#8220;ICommand.CanExecute NullReferenceException&#8221;, it might help somebody I hope&#8230;</p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=ICommand.CanExecute%28%29+and+NullReferenceException+http%3A%2F%2Femphess.net%2F%3Fp%3D31" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/&amp;title=ICommand.CanExecute%28%29+and+NullReferenceException" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/&amp;title=ICommand.CanExecute%28%29+and+NullReferenceException" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/&amp;t=ICommand.CanExecute%28%29+and+NullReferenceException" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2008/04/10/icommandcanexecute-and-nullreferenceexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Prism Drop!</title>
		<link>http://www.emphess.net/2008/04/03/new-prism-drop-2/</link>
		<comments>http://www.emphess.net/2008/04/03/new-prism-drop-2/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 16:35:39 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[p&p]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[SmartClient]]></category>

		<guid isPermaLink="false">http://www.emphess.net/?p=18</guid>
		<description><![CDATA[Again, there is a new drop for the Prism Reference Implementation. Get it here: http://www.codeplex.com/prism/Release/ProjectReleases.aspx?ReleaseId=12226 At the current release intervals, it&#8217;s hard to keep up]]></description>
			<content:encoded><![CDATA[<p>Again, there is a new drop for the Prism Reference Implementation. Get it here:</p>
<p><a href="http://www.codeplex.com/prism/Release/ProjectReleases.aspx?ReleaseId=12226">http://www.codeplex.com/prism/Release/ProjectReleases.aspx?ReleaseId=12226</a></p>
<p>At the current release intervals, it&#8217;s hard to keep up <img src='http://www.emphess.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=New+Prism+Drop%21+http%3A%2F%2Femphess.net%2F%3Fp%3D18" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2008/04/03/new-prism-drop-2/&amp;title=New+Prism+Drop%21" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2008/04/03/new-prism-drop-2/&amp;title=New+Prism+Drop%21" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2008/04/03/new-prism-drop-2/&amp;t=New+Prism+Drop%21" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2008/04/03/new-prism-drop-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tao Framework now DPI Aware!</title>
		<link>http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/</link>
		<comments>http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 16:12:45 +0000</pubDate>
		<dc:creator>Christoph Menge</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[DPI Awareness]]></category>
		<category><![CDATA[Tao]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/</guid>
		<description><![CDATA[Huge thanks to Ilmar Kruis for implementing GetDeviceCaps() in the Tao framework! With some small modifications I suggested, one can now easily develop DPI-aware OpenGL applications using C# or .NET in general! Thanks Ilmar! I will update my article on the CodeProject about OpenGL windows in Vista soon! See http://www.taoframework.com/ Get the latest version via [...]]]></description>
			<content:encoded><![CDATA[<p>Huge thanks to Ilmar Kruis for implementing GetDeviceCaps() in the Tao framework! With some small modifications I suggested, one can now easily develop DPI-aware OpenGL applications using C# or .NET in general! Thanks Ilmar!</p>
<p>I will update my article on the CodeProject about OpenGL windows in Vista soon!</p>
<p>See <a href="http://www.taoframework.com/">http://www.taoframework.com/</a></p>
<p>Get the latest version via SVN: <font face="Courier New">https://taoframework.svn.sourceforge.net/svnroot/taoframework </font></p>
<div class="tweetthis" style="text-align:right;"><p> <a rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Tao+Framework+now+DPI+Aware%21+http%3A%2F%2Femphess.net%2F%3Fp%3D15" title="Post to Twitter"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter2.png" alt="Post to Twitter" /></a> <a rel="nofollow" class="tt" href="http://delicious.com/post?url=http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/&amp;title=Tao+Framework+now+DPI+Aware%21" title="Post to Delicious"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/delicious/tt-delicious.png" alt="Post to Delicious" /></a> <a rel="nofollow" class="tt" href="http://digg.com/submit?url=http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/&amp;title=Tao+Framework+now+DPI+Aware%21" title="Post to Digg"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/digg/tt-digg.png" alt="Post to Digg" /></a> <a rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/&amp;t=Tao+Framework+now+DPI+Aware%21" title="Post to Facebook"><img class="nothumb" src="http://www.emphess.net/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook.png" alt="Post to Facebook" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.emphess.net/2008/03/28/tao-framework-now-dpi-aware/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

