<?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>dasz.at - Benutzbare Technologie &#187; Entity Framework</title>
	<atom:link href="http://dasz.at/index.php/category/microsoft/entity-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasz.at</link>
	<description>Benutzbare Technologie</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:07:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>EF + NPGSQL: &#8220;Only PrimitiveTypes can be used without qualification.&#8221;</title>
		<link>http://dasz.at/index.php/2010/07/ef-npgsql-only-primitivetypes-can-be-used-without-qualification/</link>
		<comments>http://dasz.at/index.php/2010/07/ef-npgsql-only-primitivetypes-can-be-used-without-qualification/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 12:46:35 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/?p=396</guid>
		<description><![CDATA[error 0040: The Type ... is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.]]></description>
			<content:encoded><![CDATA[<p>Are you trying to create a SSDL/EDM file for <a href="http://msdn.microsoft.com/en-us/library/aa697427.aspx">Entity Framework</a> and <a href="http://npgsql.projects.postgresql.org/">Npgsql </a>? Are you getting the following error?</p>
<blockquote><p>error 0040: The Type &#8230; is not qualified with a namespace or alias. Only PrimitiveTypes can be used without qualification.</p></blockquote>
<p>This is caused by Npgsql mapping a very sparse selection of type-names to the underlying Entity Framework type structures.</p>
<p>As of 2.0.9, the following type names are recognized:</p>
<ul>
<li>bool</li>
<li>int2</li>
<li>int4</li>
<li>float4</li>
<li>float8</li>
<li>uuid</li>
<li>numeric</li>
<li>bpchar</li>
<li>varchar</li>
<li>text</li>
<li>xml</li>
<li>timestamp</li>
<li>date</li>
<li>bytea</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2010/07/ef-npgsql-only-primitivetypes-can-be-used-without-qualification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic search with Linq</title>
		<link>http://dasz.at/index.php/2008/12/dynamic-search-with-linq/</link>
		<comments>http://dasz.at/index.php/2008/12/dynamic-search-with-linq/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 16:50:06 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/12/dynamic-search-with-linq/</guid>
		<description><![CDATA[The Problem: Find all sentences with either &#8220;fox&#8221; and &#8220;dog&#8221; and &#8220;fox&#8221; or &#8220;cat&#8221;.


string[] sentences = new string[] {
  &#34;The quick brown fox jumps over the lazy dog&#34;,
  &#34;The quick brown fox jumps over the lazy cat&#34;};
string[] findAnd = new string[] { &#34;fox&#34;, &#34;dog&#34; };
string[] findOr = new string[] { &#34;dog&#34;, &#34;cat&#34; };

The [...]]]></description>
			<content:encoded><![CDATA[<p>The Problem: Find all sentences with either &#8220;fox&#8221; and &#8220;dog&#8221; and &#8220;fox&#8221; or &#8220;cat&#8221;.</p>
<pre class="brush: c#; ">

string[] sentences = new string[] {
  &quot;The quick brown fox jumps over the lazy dog&quot;,
  &quot;The quick brown fox jumps over the lazy cat&quot;};
string[] findAnd = new string[] { &quot;fox&quot;, &quot;dog&quot; };
string[] findOr = new string[] { &quot;dog&quot;, &quot;cat&quot; };
</pre>
<p>The first part (find all) is simple:</p>
<pre class="brush: c#; ">

var queryand = sentences.AsQueryable();
foreach (string find in findAnd)
{
  string f = find;
  queryand = queryand.Where(s =&gt; s.Contains(find));
}

Console.WriteLine(string.Join(&quot;\n&quot;, queryand.ToArray()));
</pre>
<p>But how to implement to Or part? Well, google is my best friend. I found the following solution:</p>
<p><a href="http://www.albahari.com/nutshell/predicatebuilder.aspx">Predicate Builder on C# 3.5 in a Nutshell</a></p>
<p>But this solution does not work with Entity Framework: <a href="http://stackoverflow.com/questions/110314/linq-to-entities-building-where-clauses-to-test-collections-within-a-many-to-ma#131551">Predicate Builder and Entity Framework on stackoverflow.com</a></p>
<p>After implementing this solution your code will look like this:</p>
<pre class="brush: c#; ">

var predicate = Extensions.False&lt;string&gt;();
foreach (string find in findOr)
{
  string f = find;
  predicate = predicate.Or(s =&gt; s.Contains(f));
}
var queryor = sentences.AsQueryable().Where(predicate);
Console.WriteLine(string.Join(&quot;\n&quot;, queryor.ToArray()));
</pre>
<p>P.S.: You can find an ExpressionVisitor here: <a href="http://msdn.microsoft.com/en-us/library/bb882521.aspx">ExpressionVisitor at MSDN</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/12/dynamic-search-with-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unbelievable!</title>
		<link>http://dasz.at/index.php/2008/11/unbelievable/</link>
		<comments>http://dasz.at/index.php/2008/11/unbelievable/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 19:13:33 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/11/unbelievable/</guid>
		<description><![CDATA[Wow! Automatic &#8220;func eval&#8221; in Visual Studio is cool. You can even do more cool things with DebuggerDisplay (e.g. &#8220;rating = great&#8221;). If a getter has to do too much work for a debugging session to get his job done you can suppress evaluation by adding a DebuggerBrowsable attribute.
But the nice small Debug Windows &#8220;Auto&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Wow! Automatic &#8220;func eval&#8221; in Visual Studio is cool. You can even do more cool things with <a href="http://msdn.microsoft.com/en-us/library/x810d419.aspx"><code>DebuggerDisplay</code></a> (e.g. &#8220;rating = great&#8221;). If a getter has to do too much work for a debugging session to get his job done you can suppress evaluation by adding a <a href="http://dotnettipoftheday.org/tips/DebuggerBrowsableAttribute.aspx"><code>DebuggerBrowsable</code></a> attribute.</p>
<p>But the nice small Debug Windows &#8220;Auto&#8221; and &#8220;Locals&#8221; ignore these attributes. So your debugger will continue to do unnecessary work &#8211; an amazing feature. This is especially bad since there is a timeout within the debugger&#8217;s evaluator which will <strong>kill</strong> the debugger to the point of unusability when hit.</p>
<p>And yes &#8211; this is by Design:</p>
<ul>
<li><a target="_blank" href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=91772">First Microsoft Connect entry</a></li>
<li><a target="_blank" href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344925">Second Microsoft Connect entry</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/11/unbelievable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework Designer v1&#8230;</title>
		<link>http://dasz.at/index.php/2008/11/entity-framework-designer-v1/</link>
		<comments>http://dasz.at/index.php/2008/11/entity-framework-designer-v1/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 11:06:38 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/11/entity-framework-designer-v1/</guid>
		<description><![CDATA[Usually I like Entity Framework. And as I have to write the EDMX files by hand (for several reasons) I didn&#8217;t had any problems with mapping my Database and Objects.
But for another project I would like to use the designer. And I would like to use Complex Types. This is a situation where I dont [...]]]></description>
			<content:encoded><![CDATA[<p>Usually I like Entity Framework. And as I have to write the <code>EDMX</code> files by hand (for several reasons) I didn&#8217;t had any problems with mapping my Database and Objects.</p>
<p>But for another project I would like to use the designer. And I would like to use <code>Complex Type</code>s. This is a situation where I dont like Entity Framework (or better: the Designer).</p>
<blockquote><p>Error: ComplexType elements are not supported in the Entity Designer.</p></blockquote>
<p>Yep &#8211; this is a known issue:</p>
<ul>
<li><a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=362351" target="_blank">Microsoft Connect Bug</a></li>
<li><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4037284&#038;SiteID=1" target="_blank">Microsoft Forum discussion</a></li>
</ul>
<p>So I&#8217;ll try not to use Complex Types (with some bad tricks this sould be possible) or I will continue writing EDMX Files by hand&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/11/entity-framework-designer-v1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1:1 Relations and Entity Framework</title>
		<link>http://dasz.at/index.php/2008/11/11-relations-and-entity-framework/</link>
		<comments>http://dasz.at/index.php/2008/11/11-relations-and-entity-framework/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 08:02:13 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/11/11-relations-and-entity-framework/</guid>
		<description><![CDATA[Yesterday I tried to declare a 1:1 Relation in Entity Framework. As I have to write the EDMX File by hand (for various reasons) I&#8217;ve tried a straight forward way and ran into some problems. But first let me show you the sample Model:


What I tried in the EDMX File (or better: CSDL, MSL and [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I tried to declare a 1:1 Relation in Entity Framework. As I have to write the EDMX File by hand (for various reasons) I&#8217;ve tried a straight forward way and ran into some problems. But first let me show you the <em>sample</em> Model:</p>
<p><span id="more-66"></span></p>
<p><img id="image67" alt=Model src="http://dasz.at/wp-content/uploads/2008/11/model.PNG" /></p>
<p>What I tried in the EDMX File (or better: CSDL, MSL and SSDL):</p>
<p>CSDL:</p>
<pre class="brush: xml; ">

&lt;Association Name=&quot;FK_ParkingSpace_Employee&quot;&gt;
          &lt;End Role=&quot;Employee&quot; Type=&quot;Database1Model.Employee&quot; Multiplicity=&quot;0..1&quot; /&gt;
          &lt;End Role=&quot;ParkingSpace&quot; Type=&quot;Database1Model.ParkingSpace&quot; Multiplicity=&quot;0..1&quot; /&gt;
&lt;/Association&gt;
</pre>
<p>Same in the SSDL:</p>
<pre class="brush: xml; ">

&lt;Association Name=&quot;FK_ParkingSpace_Employee&quot;&gt;
  &lt;End Role=&quot;Employee&quot; Type=&quot;Database1Model.Store.Employee&quot; Multiplicity=&quot;0..1&quot; /&gt;
  &lt;End Role=&quot;ParkingSpace&quot; Type=&quot;Database1Model.Store.ParkingSpace&quot; Multiplicity=&quot;0..1&quot; /&gt;
  &lt;ReferentialConstraint&gt;
    &lt;Principal Role=&quot;Employee&quot;&gt;
      &lt;PropertyRef Name=&quot;ID&quot; /&gt;
    &lt;/Principal&gt;
    &lt;Dependent Role=&quot;ParkingSpace&quot;&gt;
      &lt;PropertyRef Name=&quot;fk_Employee&quot; /&gt;
    &lt;/Dependent&gt;
  &lt;/ReferentialConstraint&gt;
&lt;/Association&gt;
</pre>
<p>But that gave me this Error:</p>
<blockquote><p>Multiplicity is not valid in Role &#8216;ParkingSpace&#8217; in relationship &#8216;FK_ParkingSpace_Employee&#8217;. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.</p></blockquote>
<p>What? Why? OK, I didn&#8217;t understand and could not find any information on the web how to define a 1:1 Relation in Entity Framework. So I made a small test application. And the SSDL was:</p>
<pre class="brush: xml; ">

&lt;Association Name=&quot;FK_ParkingSpace_Employee&quot;&gt;
  &lt;End Role=&quot;Employee&quot; Type=&quot;Database1Model.Store.Employee&quot; Multiplicity=&quot;0..1&quot; /&gt;
  &lt;End Role=&quot;ParkingSpace&quot; Type=&quot;Database1Model.Store.ParkingSpace&quot; Multiplicity=&quot;*&quot; /&gt;
  &lt;ReferentialConstraint&gt;
    &lt;Principal Role=&quot;Employee&quot;&gt;
      &lt;PropertyRef Name=&quot;ID&quot; /&gt;
    &lt;/Principal&gt;
    &lt;Dependent Role=&quot;ParkingSpace&quot;&gt;
      &lt;PropertyRef Name=&quot;fk_Employee&quot; /&gt;
    &lt;/Dependent&gt;
  &lt;/ReferentialConstraint&gt;
&lt;/Association&gt;
</pre>
<p><strong>Multiplicity=&#8221;*&#8221;</strong></p>
<p>Ah, OK &#8211; from the Database&#8217;s viewpoint there is no 1:1 Relation. There&#8217;s a 1:n Relation. So I have to define 1:n Relation in the SSDL too. A Constraint in the Database and in the Object Model ensures, that this 1:n Relation is a 1:1 Relation. Or am I wrong?</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/11/11-relations-and-entity-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Entity Framework: EntityReference.IsLoaded</title>
		<link>http://dasz.at/index.php/2007/12/entity-framework-entityreferenceisloaded/</link>
		<comments>http://dasz.at/index.php/2007/12/entity-framework-entityreferenceisloaded/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 15:01:06 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://blog.dasz.at/index.php/2007/12/entity-framework-entityreferenceisloaded/</guid>
		<description><![CDATA[There is an issue with the Entity Framework Beta 3. If you use the EntityReference Object&#8217;s Load() Method and the Result is null then the IsLoaded bit is not set.
This is nasty because the EF will always try to load the Reference from the Database.
Or I made a mistake&#8230;
Here is an example:


[EdmRelationshipNavigationPropertyAttribute(&#34;Model&#34;, &#34;FK_Auftrag_Mitarbeiter&#34;, &#34;A_Mitarbeiter&#34;)]
public App.Mitarbeiter [...]]]></description>
			<content:encoded><![CDATA[<p>There is an issue with the Entity Framework Beta 3. If you use the EntityReference Object&#8217;s Load() Method and the Result is null then the IsLoaded bit is not set.</p>
<p>This is nasty because the EF will always try to load the Reference from the Database.</p>
<p>Or I made a mistake&#8230;</p>
<p>Here is an example:</p>
<pre class="brush: c#; ">

[EdmRelationshipNavigationPropertyAttribute(&quot;Model&quot;, &quot;FK_Auftrag_Mitarbeiter&quot;, &quot;A_Mitarbeiter&quot;)]
public App.Mitarbeiter Mitarbeiter
{
  get
  {
    EntityReferenceMitarbeiter&gt; r =
      ((IEntityWithRelationships)(this)).RelationshipManager
      .GetRelatedReferenceMitarbeiter&gt;
      (&quot;Model.FK_Auftrag_Mitarbeiter&quot;, &quot;A_Mitarbeiter&quot;);

    if (!r.IsLoaded)
      r.Load();

    return r.Value;
  }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2007/12/entity-framework-entityreferenceisloaded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework: How to embed C/M/S Files</title>
		<link>http://dasz.at/index.php/2007/12/entity-framework-how-to-embed-cms-files/</link>
		<comments>http://dasz.at/index.php/2007/12/entity-framework-how-to-embed-cms-files/#comments</comments>
		<pubDate>Fri, 21 Dec 2007 12:12:36 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://blog.dasz.at/index.php/2007/12/entity-framework-how-to-embed-cms-files/</guid>
		<description><![CDATA[That&#8217;s simple:

Embed your files as a resource in your DLL
In your app.config change the connectionstring from:



&#60;add name=&#34;KistlContext&#34;
  connectionString=&#34;metadata=.\Model.csdl&#124;.\Model.ssdl&#124;.\Model.msl;
  provider=System.Data.SqlClient;
  provider connection string=&#039;Data Source=.\SQLEXPRESS;
    Initial Catalog=YourDatabase;
    Integrated Security=True;
    MultipleActiveResultSets=true;&#039;&#34;
  providerName=&#34;System.Data.EntityClient&#34; /&#62;

to:


&#60;add name=&#34;KistlContext&#34;
  connectionString=&#34;metadata=res://*;
  provider=System.Data.SqlClient;
  provider connection string=&#039;Data Source=.\SQLEXPRESS;
   [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s simple:</p>
<ol>
<li>Embed your files as a resource in your DLL</li>
<li>In your app.config change the connectionstring from:</li>
</ol>
<pre class="brush: xml; ">

&lt;add name=&quot;KistlContext&quot;
  connectionString=&quot;metadata=.\Model.csdl|.\Model.ssdl|.\Model.msl;
  provider=System.Data.SqlClient;
  provider connection string=&#039;Data Source=.\SQLEXPRESS;
    Initial Catalog=YourDatabase;
    Integrated Security=True;
    MultipleActiveResultSets=true;&#039;&quot;
  providerName=&quot;System.Data.EntityClient&quot; /&gt;
</pre>
<p>to:</p>
<pre class="brush: xml; ">

&lt;add name=&quot;KistlContext&quot;
  connectionString=&quot;metadata=res://*;
  provider=System.Data.SqlClient;
  provider connection string=&#039;Data Source=.\SQLEXPRESS;
    Initial Catalog=YourDatabase;
    Integrated Security=True;
    MultipleActiveResultSets=true;&#039;&quot;
  providerName=&quot;System.Data.EntityClient&quot; /&gt;
</pre>
<p>It does not matter in which assembly the model is embedded.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2007/12/entity-framework-how-to-embed-cms-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
