<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cherry pie &#38; damn good coffee</title>
	<atom:link href="http://ivowiblo.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivowiblo.wordpress.com</link>
	<description>Brilliant... I have no idea what&#039;s going on.</description>
	<lastBuildDate>Mon, 29 Aug 2011 19:05:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ivowiblo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Cherry pie &#38; damn good coffee</title>
		<link>http://ivowiblo.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ivowiblo.wordpress.com/osd.xml" title="Cherry pie &#38; damn good coffee" />
	<atom:link rel='hub' href='http://ivowiblo.wordpress.com/?pushpress=hub'/>
		<item>
		<title>NHibernate Mapping tester</title>
		<link>http://ivowiblo.wordpress.com/2011/08/29/nhibernate-mapping-tester/</link>
		<comments>http://ivowiblo.wordpress.com/2011/08/29/nhibernate-mapping-tester/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 19:05:26 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=543</guid>
		<description><![CDATA[When using NHibernate, you often need to check if your mappings matches the model and database. Using frameworks like FluentNHibernate usually helps form the compilation perspective, because your mappings won&#8217;t compile if there&#8217;s any misspelled property or class. But for convensions and database schemas, it&#8217;s possible to have a mismatch. The following code is a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=543&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When using <a href="http://nhforge.org" title="NHibernate">NHibernate</a>, you often need to check if your mappings matches the model and database. Using frameworks like <a href="http://fluentnhibernate.org/" title="FluentNHibernate">FluentNHibernate</a> usually helps form the compilation perspective, because your mappings won&#8217;t compile if there&#8217;s any misspelled property or class. But for convensions and database schemas, it&#8217;s possible to have a mismatch.<br />
The following code is a test that will check every property on every mapped class and then every collection. Basically, it queries each type and each collection so NHibernate needs to create the sql statement and execute it. If any error is thrown, you will notice. </p>
<pre class="brush: csharp;">
[Test]
public void AllMappingsAreOk()
{
	var session = GetCurrentNHibernateSession();
	var errors = new List&lt;string&gt;();

	foreach (var entry in session.SessionFactory.GetAllClassMetadata())
	{
		var type = entry.Key;
		var data = entry.Value;

		try
		{
			session.CreateCriteria(type).SetMaxResults(0).List();
		}
		catch (Exception e)
		{
			errors.Add(string.Format(&quot;Error getting type {0}: {1}&quot;, type, e.Message));
		}

		foreach (var collection in data.PropertyNames.Where(x =&gt; data.GetPropertyType(x).IsCollectionType))
		{
			try
			{
				session.CreateCriteria(type).CreateCriteria(collection).SetMaxResults(0).List();
			}
			catch (Exception e)
			{
				errors.Add(string.Format(&quot;Error getting collection {0}.{1}: {2}&quot;,
										 type,
										 collection,
										 e.Message));
			}
		}
	}
	Assert.True(errors.Count == 0, string.Join(Environment.NewLine, errors));
}
</pre>
<p>This piece of code was really helpful in the past and is following me in every project involving NHibernate. It seemed useful to share <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/543/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/543/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/543/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=543&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/08/29/nhibernate-mapping-tester/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>MemoDb 0.1.2 beta released!</title>
		<link>http://ivowiblo.wordpress.com/2011/07/25/memodb-0-1-2-beta-released/</link>
		<comments>http://ivowiblo.wordpress.com/2011/07/25/memodb-0-1-2-beta-released/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 15:38:20 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[MemoDb]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[memodb]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=539</guid>
		<description><![CDATA[Glad to announce the beta of MemoDb is out. It includes Circular references support Support for .NET 3.5 and Mono 2.0 Thanks to Yallie for the work on supporting more targets than 4.0! Here is the release: http://memodb.codeplex.com/releases/view/70652<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=539&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Glad to announce the beta of <a href="http://memodb.codeplex.com" title="MemoDb">MemoDb</a> is out. It includes</p>
<ul>
<li>Circular references support</li>
<li>Support for .NET 3.5 and Mono 2.0</li>
</ul>
<p>Thanks to Yallie for the work on supporting more targets than 4.0!</p>
<p>Here is the release: <a href="http://memodb.codeplex.com/releases/view/70652">http://memodb.codeplex.com/releases/view/70652</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/539/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/539/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/539/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=539&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/07/25/memodb-0-1-2-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq &#8220;in&#8221; clause</title>
		<link>http://ivowiblo.wordpress.com/2011/07/14/linq-in-clause/</link>
		<comments>http://ivowiblo.wordpress.com/2011/07/14/linq-in-clause/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 03:52:55 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[sharepoint]]></category>
		<category><![CDATA[in]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=533</guid>
		<description><![CDATA[So&#8230; today I needed to do a simple query like &#8230;with Linq. In the objects world this is managed using the Contains method of IList. The perfect Linq for the previous query is: The problem with this is no all Linq providers understands it. And SPLinq (Linq for SharePoint) is one of those who doesn&#8217;t. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=533&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So&#8230; today I needed to do a simple query like</p>
<pre class="brush: sql;">
SELECT * FROM Activities a Where a.Community in ('Community 1', 'Community 2', 'Community 3')
</pre>
<p>&#8230;with Linq.</p>
<p>In the objects world this is managed using the Contains method of IList. The perfect Linq for the previous query is:</p>
<pre class="brush: csharp;">
var communities = new []{ &quot;Community 1&quot;, &quot;Community 2&quot;, &quot;Community 3&quot; };
var result = activities.Where(x =&gt; communities.Contains(x.Community));
</pre>
<p>The problem with this is no all Linq providers understands it. And SPLinq (Linq for SharePoint) is one of those who doesn&#8217;t.</p>
<p>The other way to handle this kinds of queries is, in SQL:</p>
<pre class="brush: sql;">
SELECT * FROM Activities a Where a.Community = 'Community 1' or a.Community = 'Community 2' or a.Community =  'Community 3'
</pre>
<p>But how to create the Linq query dynamically? Well&#8230; All these months working with <a href="http://magiq.codeplex.com">Magiq</a> gived me the ability of compile Expression trees in my head <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is the code needed:</p>
<pre class="brush: csharp;">
private static IQueryable&lt;T&gt; Where&lt;T&gt;(this IQueryable&lt;T&gt; self, Expression&lt;Func&lt;T,object&gt;&gt; property, IEnumerable&lt;string&gt; @in)
{
	var propertyName = ((MemberExpression)property.Body).Member.Name;

	Expression expression = null;

	var x = Expression.Parameter(typeof (ActivityItem), &quot;x&quot;);
	foreach (var community in @in)
	{
		var propertyExpression = Expression.Property(x, propertyName);
		var equal = Expression.Equal(propertyExpression, Expression.Constant(community));
		expression = expression == null ? equal : Expression.Or(expression, equal);
	}

	if (expression == null)
		return list;

	var lamda = Expression.Lambda&lt;Func&lt;T, bool&gt;&gt;(expression, x);
	return self.Where(lamda);
}

var communities = new []{ &quot;Community 1&quot;, &quot;Community 2&quot;, &quot;Community 3&quot; };
var result = activities.Where(x =&gt; x.Community, @in: communities);
</pre>
<p>Linq rules!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/533/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/533/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/533/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=533&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/07/14/linq-in-clause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>Magiq to Entities &#8211; An update</title>
		<link>http://ivowiblo.wordpress.com/2011/05/07/magiq-to-entities-an-update/</link>
		<comments>http://ivowiblo.wordpress.com/2011/05/07/magiq-to-entities-an-update/#comments</comments>
		<pubDate>Sat, 07 May 2011 19:04:55 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Magiq]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq-to-sql]]></category>
		<category><![CDATA[magiq-to-entities]]></category>
		<category><![CDATA[magiq-to-sql]]></category>
		<category><![CDATA[software design]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=526</guid>
		<description><![CDATA[The past days I&#8217;ve been working on making Magiq work with Entity Framework. First I tried to work with the MetadataWorkspace and I gave up, &#8217;cause its really impossible to get the mapping information. Luckily, I found Linq to Edmx project who does exactly what I needed. Then I had some troubles working with the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=526&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The past days I&#8217;ve been working on making <a href="http://magiq.codeplex.com/">Magiq</a> work with Entity Framework.</p>
<p>First I tried to work with the MetadataWorkspace and I gave up, &#8217;cause its really impossible to get the mapping information. Luckily, I found <a href="http://linqtoedmx.codeplex.com/">Linq to Edmx</a> project who does exactly what I needed.</p>
<p>Then I had some troubles working with the Queryables generated by the ObjectSets. Basically, the expression generated calls methods that doesn&#8217;t work and are there only to give information in the expression. So the expression is not something you can compile and execute. As big part of Magiq is to manipulate expression trees, that was a really big problem. I needed to figure out how to change the source queryable (I mean, the queryable where all the methods are applied to) to a simple ObjectSet. Besides it works now, I&#8217;m still working to get to a nicer way (you don&#8217;t want to know what I have done to make it work&#8230;).</p>
<p>Since <a href="/2011/04/28/magiq-new-release-and-api-changes/">I changed the insert API from having the new item expression (the new{&#8230;}) outside to have it as a select</a>, I had to break the query in two, the select and the &#8220;rest&#8221;. Ok, that gave me more headaches <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>But the biggest problem was when Entity Framework started to change the order of the columns in the select (and add new columns). Let me explain how Linq to Sql works:</p>
<p>If you do this:</p>
<pre class="brush: csharp;">
items.Where( ... ).Select( x =&gt; new { A = x.Prop1, B = x.Prop2, C = x.Prop2 /*again*/ });
</pre>
<p>Linq to sql transate it to:</p>
<pre class="brush: sql;">
SELECT prop1, prop2, prop2 FROM items WHERE ...
</pre>
<p>But Entity Framework removes the repeated columns and maybe reorders them, giving you something like:</p>
<pre class="brush: sql;">
SELECT prop2, prop1 FROM items WHERE ...
</pre>
<p>You don&#8217;t have any idea of the reflection tricks I had to make to get those property-select columns mapping.</p>
<p>But well, those are not bad news at all. I mean I could work around them and I can say Magiq now supports Entity Framework (with a few restrictions). Those are:</p>
<ul>
<li><strong>Only Table per class hierarchy inheritance is supported.</strong> I&#8217;m currently working on the Table per concrete class and Table per type strategies</li>
<li><strong>Only mapped associations are supported.</strong> This means associations based on foreign keys are not (yet).</li>
<li><strong>Only mapped POCOs are supported.</strong> This means Self Tracking entities and Code First are not (yet).
</ul>
<p>Keep in touch for the updates <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/526/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=526&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/05/07/magiq-to-entities-an-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>Magiq: New release and API Changes</title>
		<link>http://ivowiblo.wordpress.com/2011/04/28/magiq-new-release-and-api-changes/</link>
		<comments>http://ivowiblo.wordpress.com/2011/04/28/magiq-new-release-and-api-changes/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 23:06:37 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Magiq]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq-to-sql]]></category>
		<category><![CDATA[magiq-to-sql]]></category>
		<category><![CDATA[mass delete]]></category>
		<category><![CDATA[mass insert]]></category>
		<category><![CDATA[mass update]]></category>
		<category><![CDATA[queryable collections]]></category>
		<category><![CDATA[software design]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=510</guid>
		<description><![CDATA[New release of Magiq, supporting Linq-to-sql. This should be the last one for Linq-to-sql, the next one I hope will have the minimal support for Entity Framework. You can download it from here. For those reading this for the first time (?), Magiq is a framework that let you do mass operation in a Linq [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=510&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>New release of <a href="http://magiq.codeplex.com">Magiq</a>, supporting Linq-to-sql. This should be the last one for Linq-to-sql, the next one I hope will have the minimal support for Entity Framework. You can download it from <a href="http://magiq.codeplex.com/releases/65354/download/233629">here</a>.</p>
<p>For those reading this for the first time (?), Magiq is a framework that let you do mass operation in a Linq fashion.</p>
<p>So&#8230; as Magiq will be supporting Entity Framework soon, it made sense to change the API to make it support Entity Framework limitations. Also, I found a better Insert API (the one that always made me doubt!). The changes are:</p>
<p><strong>Query extension method changes</strong><br />
The new method looks like this: </p>
<pre class="brush: csharp;">
country.Query(x =&gt; x.Cities);
</pre>
<p>It will return an IQueryable that will let you do all the Magiq stuff.</p>
<p><strong>No more IEnumerable support</strong><br />
This is a hard one. You can only do Magiq stuff between IQueryables. If you have an IEnumerable collection, use the Query extension method of it parent entity.</p>
<p><strong>New Insert API</strong></p>
<pre class="brush: csharp;">
destination.Insert( source.Where( condition ).Select( new Item{ ... } ));
</pre>
<p>Cool, isn&#8217;t it? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Entities extension methods</strong><br />
Because we no longer support extension methods over collections but over the entity, there are some extension methods for improving the code readavility.</p>
<p><em>Delete</em></p>
<pre class="brush: csharp;">
entity.Delete(x =&gt; x.Collection.Where( condition ));
//Instead of
entity.Query(x =&gt; x.Collection).Where( condition ).Delete();
</pre>
<p><em>Update</em></p>
<pre class="brush: csharp;">
entity.Update(x =&gt; x.Collection.Where( condition ).Set(x =&gt; x.Prop, value));
//Instead of
entity.Query(x =&gt; x.Collection).Where( condition ).Set(x =&gt; x.Prop, value).Update();
</pre>
<p><em>Query</em></p>
<pre class="brush: csharp;">
entity.Query(x =&gt; x.Collection.Where( condition ));
//Instead of
entity.Query(x =&gt; x.Collection).Where( condition );
</pre>
<p><em>Insert</em></p>
<pre class="brush: csharp;">
entity.InsertInto( x =&gt; x.Collection, source.Where( condition ).Select( new Item{ ... } ));
//Instead of
entity.Query(x =&gt; x.Collection)
      .Insert( source.Where( condition ).Select( new Item{ ... } ));
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/510/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/510/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/510/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=510&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/04/28/magiq-new-release-and-api-changes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>Weak Dictionaries</title>
		<link>http://ivowiblo.wordpress.com/2011/04/25/weak-dictionarie/</link>
		<comments>http://ivowiblo.wordpress.com/2011/04/25/weak-dictionarie/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 22:55:11 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[software design]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=500</guid>
		<description><![CDATA[Suppose you need a complex/slow process for generating something and you want to cache it. But you don&#8217;t know if that something will be used a lot of just a few times. If it is the last case, you don&#8217;t care executing again the process, but it&#8217;s different if it&#8217;s accessed several times. WeakDictionary to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=500&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you need a complex/slow process for generating something and you want to cache it. But you don&#8217;t know if that something will be used a lot of just a few times. If it is the last case, you don&#8217;t care executing again the process, but it&#8217;s different if it&#8217;s accessed several times.</p>
<p><strong>WeakDictionary to the rescue!</strong></p>
<p>This dictionary, basically, maintains each value in a class that could reference it as a weakreference if it wasn&#8217;t accessed often and if the amount of items is bigger than a threshold defined:</p>
<pre class="brush: csharp;">
var d = new WeakDictionary&lt;int,SomeClass&gt;(3);
d.Add(1, new SomeClass());
d.Add(2, new SomeClass());
d.Add(3, new SomeClass());

//We use the values...
var bla = d[1];
var bla1 = d[1];
var bla2 = d[1];
var bla3 = d[2];
var bla4 = d[2];
var bla5 = d[3];

//When we try to add an item and we are passing the threshold, it will weak the less used reference
d.Add(4, new SomeClass());
</pre>
<p>d[3] value is now maintained with a weak reference. If it&#8217;s used before it&#8217;s garbage-collected, it will be alive again and d[2] will be the &#8220;weak one&#8221;.</p>
<p>You can download the code <a href="http://ivowiblo.googlecode.com/svn/WeakDictionary/">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/500/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/500/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/500/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=500&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/04/25/weak-dictionarie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>Magiq: Next steps &#8211; different approach</title>
		<link>http://ivowiblo.wordpress.com/2011/04/25/magiq-next-steps-different-approach/</link>
		<comments>http://ivowiblo.wordpress.com/2011/04/25/magiq-next-steps-different-approach/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 14:33:03 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Magiq]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[EntityFramework]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Linq-to-sql]]></category>
		<category><![CDATA[queryable collections]]></category>
		<category><![CDATA[software design]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=494</guid>
		<description><![CDATA[Back to the Magiq game! I started to play with Entity Framework 4 and realized some stuff is not possible the way it was designed. It has to do with the way EF4 manages Lazy collections. In Linq-to-sql and NHibernate, the collection itself has the property of being lazy, materializing all the objects when you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=494&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Back to the <a href="http://magiq.codeplex.com" title="magiq">Magiq</a> game!</p>
<p>I started to play with Entity Framework 4 and realized some stuff is not possible the way it was designed. It has to do with the way EF4 manages Lazy collections.<br />
In Linq-to-sql and NHibernate, the collection itself has the property of being lazy, materializing all the objects when you iterate it. For example, in Linq-to-sql collections are EntitySets. Because of this, you can do this:</p>
<pre class="brush: csharp;">
parent.Children.Delete(x =&gt; x.SomeCondition);
</pre>
<p>This is because the Children collection contains all the information needed: </p>
<ul>
<li>The parent object instance, for getting the Id</li>
<li>The collection name</li>
</ul>
<p>Sadly, EntityFramework handles this feature in a different way: Is the parent object the lazy one and the collection is populated when you access the collection propery and not when you iterate it. Because of that, in the moment you do parent.Children you have executed the query in the database.<br />
This lead us to have a different API, that avoid accessing the collection property. What I thought is:</p>
<pre class="brush: csharp;">
parent.Delete(p =&gt; p.Children.Where(x =&gt; x.SomeCondition));
</pre>
<p>It&#8217;s not so bad, I must Say, and it also let us do things like</p>
<pre class="brush: csharp;">
parent.Delete(p =&gt; p.SomeObjectInTheMiddle.Children.Where(x =&gt; x.SomeCondition));
</pre>
<p> without executing the query for getting the SomeObjectInTheMiddle instance.</p>
<p>Also, I give up with Magiq-to-NHibernate, at least for a while. NHibernate has huge features, it let you map your classes in thousand of different ways, and that is awesome. But also it makes it really complicated to work with. And since NHibernate already has mass operation support, it makes sense to stop worring. At least, as I said before, for a while.</p>
<p>So, I will be working on changing the Query API and only for Linq-to-Sql and Entity Framework. Everyone is welcome to contribute implementations for other ORMs.</p>
<p>Next step: Changing the API</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/494/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/494/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/494/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=494&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/04/25/magiq-next-steps-different-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>MemoDb 0.1.0 alpha released!</title>
		<link>http://ivowiblo.wordpress.com/2011/02/11/memodb-0-1-0-alpha-released/</link>
		<comments>http://ivowiblo.wordpress.com/2011/02/11/memodb-0-1-0-alpha-released/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 13:10:11 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MemoDb]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=487</guid>
		<description><![CDATA[The first release of MemoDb is out! It supports: Inserts Updates Delete Insert references and collections by cascade Delete collection children by cascade (aka cascade-all-delete-orphans) EntityRef references Id auto generation (With defaults for ints, long and guid) You can download it from here. To see other posts of MemoDb: Introduction to MemoDb MemoDb: Collections support [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=487&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The first release of <a href="http://memodb.codeplex.com">MemoDb</a> is out!<br />
It supports:</p>
<ul>
<li>Inserts</li>
<li>Updates</li>
<li>Delete</li>
<li>Insert references and collections by cascade</li>
<li>Delete collection children by cascade (aka cascade-all-delete-orphans)</li>
<li>EntityRef references</li>
<li>Id auto generation (With defaults for ints, long and guid)
</ul>
<p>You can download it from <a href="http://memodb.codeplex.com/releases/view/60772">here</a>.</p>
<p>To see other posts of MemoDb:</p>
<ul>
<li><a href="/2011/02/03/introduction-to-memodb/">Introduction to MemoDb</a></li>
<li><a href="/2011/02/04/memodb-collections-support/">MemoDb: Collections support</a></li>
<li><a href="/2011/02/04/memodb-auto-assign-id-support/">MemoDb: Auto assign id support</a></li>
<li><a href="/2011/02/10/memodb-cascades-and-collections-support/">MemoDb: Cascades and Collections support</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/487/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/487/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/487/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=487&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/02/11/memodb-0-1-0-alpha-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>MemoDb: Cascades and Collections support</title>
		<link>http://ivowiblo.wordpress.com/2011/02/10/memodb-cascades-and-collections-support/</link>
		<comments>http://ivowiblo.wordpress.com/2011/02/10/memodb-cascades-and-collections-support/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 23:13:36 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MemoDb]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=481</guid>
		<description><![CDATA[I&#8217;ve been implementing some new features and I think it&#8217;s ready for an alpha release. I&#8217;ll be uploading the files in codeplex. To follow the MemoDb posts saga: Introduction to MemoDb MemoDb: Collections support MemoDb: Auto assign id support Now, MemoDb supports: Delete Collections EntityRef (for LinqToSql support) Cascade inserts Cascade delete on collections children [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=481&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been implementing some new features and I think it&#8217;s ready for an alpha release. I&#8217;ll be uploading the files in <a href="http://memodb.codeplex.com">codeplex</a>.</p>
<p>To follow the MemoDb posts saga:</p>
<ul>
<li><a href="/2011/02/03/introduction-to-memodb/">Introduction to MemoDb</a></li>
<li><a href="/2011/02/04/memodb-collections-support/">MemoDb: Collections support</a></li>
<li><a href="/2011/02/04/memodb-auto-assign-id-support/">MemoDb: Auto assign id support</a></li>
</ul>
<p>Now, <a href="http://memodb.codeplex.com">MemoDb</a> supports:</p>
<ul>
<li>Delete</li>
<li>Collections</li>
<li>EntityRef (for LinqToSql support)</li>
<li>Cascade inserts</li>
<li>Cascade delete on collections children (aka all-delete-orphans)</li>
</ul>
<p><strong>Delete</strong><br />
Pretty simple, it let you delete objects:</p>
<pre class="brush: csharp;">
using (var s = memo.CreateSession())
{
	var city= s.GetById&lt;City&gt;(1);
	s.Delete(city);
	s.Flush();
}
</pre>
<p><strong>Cascade Inserts</strong><br />
You can configure MemoDb to insert new references by default:</p>
<pre class="brush: csharp;">
var memo = new Memo(insertByCascadeByDefault: true)
</pre>
<p>Or you can specify the behaviour just for one relationship:</p>
<pre class="brush: csharp;">
 var memo = new Memo()
           .Map&lt;City&gt;(c =&gt; c.CasacadeInsert(x =&gt; x.Country))
           .Map&lt;Country&gt;();
</pre>
<p><strong>Cascade Delete Orphans</strong><br />
You can configure MemoDb to delete collections children by cascade when the parent object is deleted by default:</p>
<pre class="brush: csharp;">
var memo = new Memo(deleteOrphansByCascadeByDefault: true)
</pre>
<p>Or you can specify the behaviour just for one collection:</p>
<pre class="brush: csharp;">
 var memo = new Memo()
           .Map&lt;City&gt;()
           .Map&lt;Country&gt;(c =&gt; c.CasacadeDeleteOrphans(x =&gt; x.Cities));
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/481/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=481&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/02/10/memodb-cascades-and-collections-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
		<item>
		<title>MemoDb: Auto assign id support</title>
		<link>http://ivowiblo.wordpress.com/2011/02/04/memodb-auto-assign-id-support/</link>
		<comments>http://ivowiblo.wordpress.com/2011/02/04/memodb-auto-assign-id-support/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 16:30:45 +0000</pubDate>
		<dc:creator>ivowiblo</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MemoDb]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://ivowiblo.wordpress.com/?p=469</guid>
		<description><![CDATA[MemoDb is a in-memory-linq-database useful for mocking linq repositories in unit testing. You can track the previous posts: Introduction to MemoDb MemoDb: Collections support Today I will talk about the generation of ids for new entities. As MemoDb stands for mocking real linq orms and, generally, the underlying databases auto assign the ids. By now, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=469&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://memodb.codeplex.com">MemoDb</a> is a in-memory-linq-database useful for mocking linq repositories in unit testing. You can track the previous posts:</p>
<ul>
<li><a href="/2011/02/03/introduction-to-memodb/">Introduction to MemoDb</a></li>
<li><a href="/2011/02/04/memodb-collections-support/">MemoDb: Collections support</a></li>
</ul>
<p>Today I will talk about the generation of ids for new entities. As <a href="http://memodb.codeplex.com">MemoDb</a> stands for mocking real linq orms and, generally, the underlying databases auto assign the ids.</p>
<pre class="brush: csharp;">
var memo = new Memo()
     .Map&lt;MyEntity&gt;(x=&gt;x.Id(x =&gt; x.Id, autoAssign: true));
</pre>
<p>By now, MemoDb supports:</p>
<ul>
<li>Int32: increments the last id.</li>
<li>Int64: increments the last id.</li>
<li>Guid: Generates a new Guid.</li>
</ul>
<p>If you need another strategy or to map another id type, you can specify the strategy as a delegate:</p>
<pre class="brush: csharp;">
var memo = new Memo()
     .Map&lt;MyEntity&gt;(x=&gt;x.Id(x =&gt; x.Id, last =&gt; last + 10));
</pre>
<p>In the example above, the generation is made adding 10 to the last id assigned.<br />
By default, MemoDb will assign the ids when the object is inserted. You can override this behavior by configuration:</p>
<pre class="brush: csharp;">
var memo = new Memo(assignIdMode: AssignIdMode.OnFlush)
     .Map&lt;MyEntity&gt;();
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ivowiblo.wordpress.com/469/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ivowiblo.wordpress.com/469/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ivowiblo.wordpress.com/469/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ivowiblo.wordpress.com&amp;blog=10791993&amp;post=469&amp;subd=ivowiblo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ivowiblo.wordpress.com/2011/02/04/memodb-auto-assign-id-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/51a7e1c7bc2bf371ab6c69574f0c3fc4?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">ivowiblo</media:title>
		</media:content>
	</item>
	</channel>
</rss>
