<?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>Identity Interface</title>
	<atom:link href="http://jonshern.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonshern.com</link>
	<description>I should know better</description>
	<lastBuildDate>Thu, 17 Dec 2009 23:43:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Finding a place for WCF RIA in existing applications</title>
		<link>http://jonshern.com/2009/12/17/finding-a-place-for-wcf-ria-in-existing-applications/</link>
		<comments>http://jonshern.com/2009/12/17/finding-a-place-for-wcf-ria-in-existing-applications/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 23:43:56 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ria]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[entity framework]]></category>
		<category><![CDATA[poco]]></category>
		<category><![CDATA[silvlerlight]]></category>

		<guid isPermaLink="false">http://jonshern.com/2009/12/17/finding-a-place-for-wcf-ria-in-existing-applications/</guid>
		<description><![CDATA[Works with Entity Framework 4.0 CTP 2
My application so far ...
The premise of this application is to create a way for one or more people to create a common practice routine, set goals, and compare their progress.
I started this application with the intention of using Entity Framework 4 and RIA. 
I started having problem with [...]]]></description>
			<content:encoded><![CDATA[<p>Works with Entity Framework 4.0 CTP 2</p>
<p>My application so far ...</p>
<p>The premise of this application is to create a way for one or more people to create a common practice routine, set goals, and compare their progress.</p>
<p>I started this application with the intention of using Entity Framework 4 and RIA. </p>
<p>I started having problem with inserting from the server side, so I decided to start with a more basic model, and work my way into RIA and EF.</p>
<p>My data model looks like this</p>
<p><a href="http://jonshern.com/wp-content/uploads/2009/12/clip_image002.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://jonshern.com/wp-content/uploads/2009/12/clip_image002_thumb.jpg" width="244" height="239" /></a></p>
<p>I started with the problem of how do I save disconnected entities across a service boundary.</p>
<p>I found that converting to Self Tracking Entities solved this problem very elegantly.</p>
<h5></h5>
<h6>Problem Number 2</h6>
<h6>Option 1(The hard way)</h6>
<p>I want the entire object graph on the client side, and I would like to be able dynamically generate a graph using a collection of Task Items.</p>
<p>I could do this by creating a silvlerlight class library sharing the objects(once they are converted to POCO’s) and using linking to share the objects between layers.</p>
<p>I would then have to build up the structure on the client side, using a series of async loads.</p>
<p>This is a lot of work. I have done it before, and every time I do it, I feel like I just wasted time I will never get back.</p>
<h6>Option 2 - Use RIA and POCO.</h6>
<p>I know that RIA sits in between the Server and the Client </p>
<p><a href="http://jonshern.com/wp-content/uploads/2009/12/clip_image004.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://jonshern.com/wp-content/uploads/2009/12/clip_image004_thumb.jpg" width="244" height="85" /></a></p>
<p>(Shamelessly stolen from Brad Abrahams excellent RIA Services video)</p>
<p><strong>So how do I add RIA to this project?</strong></p>
<p>&#160;</p>
<p><strong>Setting up your POCO entities</strong></p>
<p>I have an entity class for Tasks</p>
<pre class="code"><span style="color: blue">namespace </span>PracticeManager.Common.Entities
{
    <span style="color: blue">public class </span><span style="color: #2b91af">Task
    </span>{
        [<span style="color: #2b91af">Key</span>]
        <span style="color: blue">public virtual int </span>Id { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual string </span>Name { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual </span><span style="color: #2b91af">DateTime </span>CreatedTime { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual </span><span style="color: #2b91af">DateTime </span>ModifiedTime { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual string </span>Status { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual string </span>MeasurementUnit { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual string </span>UserName { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public virtual int</span>? CommentId { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

        <span style="color: blue">public </span><span style="color: #2b91af">ICollection</span>&lt;<span style="color: #2b91af">TaskItem</span>&gt; TaskItems { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public </span><span style="color: #2b91af">ICollection</span>&lt;<span style="color: #2b91af">Goal</span>&gt; Goals { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public </span><span style="color: #2b91af">Comment </span>Comment { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public </span><span style="color: #2b91af">ICollection</span>&lt;<span style="color: #2b91af">Taunt</span>&gt; Taunts { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public </span><span style="color: #2b91af">ICollection</span>&lt;<span style="color: #2b91af">Challenge</span>&gt; Challenges { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }
        <span style="color: blue">public </span><span style="color: #2b91af">ICollection</span>&lt;<span style="color: #2b91af">Challenge</span>&gt; Challenges_1 { <span style="color: blue">get</span>; <span style="color: blue">set</span>; }

    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>I have my context class.</p>
<pre class="code"><span style="color: blue">namespace </span>PracticeManager.Server.Business.DataContext
{
    <span style="color: blue">public class </span><span style="color: #2b91af">TaskDataContext </span>: <span style="color: #2b91af">ObjectContext
    </span>{
        <span style="color: blue">private </span><span style="color: #2b91af">ObjectSet</span>&lt;<span style="color: #2b91af">Task</span>&gt; _tasks;

        <span style="color: blue">public </span>TaskDataContext(<span style="color: blue">string </span>connectionString)
            : <span style="color: blue">base</span>(connectionString, <span style="color: #a31515">&quot;PracticeModelContainer&quot;</span>)
        {

        }

        <span style="color: blue">public </span><span style="color: #2b91af">ObjectSet</span>&lt;<span style="color: #2b91af">Task</span>&gt; Tasks
        {
            <span style="color: blue">get
            </span>{
                <span style="color: blue">return </span>_tasks ?? (_tasks = <span style="color: blue">base</span>.CreateObjectSet&lt;<span style="color: #2b91af">Task</span>&gt;());
            }

        }

    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>This covers the data loading portion.</p>
<p><strong>Hooking up RIA Services</strong></p>
<p>In your Web Project add a Domain Service class.</p>
<p>A wizard will appear, I avoided the wizard. I want to do this programmatically.</p>
<p>&#160;</p>
<p>My domain class is pretty simple, for now I just want a list of tasks.</p>
<pre class="code">[<span style="color: #2b91af">EnableClientAccess</span>()]
<span style="color: blue">public class </span><span style="color: #2b91af">PracticeManagerDomainService </span>: <span style="color: #2b91af">DomainService
</span>{
    <span style="color: blue">private </span><span style="color: #2b91af">TaskDataContext </span>taskContext;

    <span style="color: blue">public </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Task</span>&gt; GetTasks()
    {
        <span style="color: blue">var </span>cnxString = <span style="color: #2b91af">ConfigurationManager</span>.ConnectionStrings[<span style="color: #a31515">&quot;PracticeModelContainer&quot;</span>].ConnectionString;
        taskContext = <span style="color: blue">new </span><span style="color: #2b91af">TaskDataContext</span>(cnxString);
        <span style="color: blue">var </span>tasks = taskContext.Tasks;

        <span style="color: blue">return </span>tasks;
    }
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>This is far from pretty, I need to move my connection string out of the method, but this will work.</p>
<p><strong>On the client side</strong></p>
<p>In my code behind I have two methods.</p>
<pre class="code"><span style="color: blue">public void </span>LoadTasks()
{
    <span style="color: #2b91af">EntityQuery</span>&lt;<span style="color: #2b91af">Task</span>&gt; taskQuery = _practiceManagerDomainContext.GetTasksQuery();
    _practiceManagerDomainContext.Load(taskQuery, <span style="color: blue">this</span>.OnTasksLoaded, <span style="color: blue">null</span>);
}

<span style="color: blue">private void </span>OnTasksLoaded(<span style="color: #2b91af">LoadOperation</span>&lt;<span style="color: #2b91af">Task</span>&gt; loadOperation)
{
    nameComboBox.ItemsSource = _practiceManagerDomainContext.Tasks;
}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>This takes care of the async load and connecting to the service.</p>
<p>The Task object comes across because of its exposure in the domain service class.</p>
<p>The namespace is even the same as the server side, which indicates it is the same object. Not just a service proxy.</p>
<p>Once I call the LoadTasks method, I will get a dropdown populated with tasks.</p>
<p>That is all I need to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/12/17/finding-a-place-for-wcf-ria-in-existing-applications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Self Tracking Entities in Entity Framework 4 to fix the error &#8211; The object could not be added or attached &#8230;</title>
		<link>http://jonshern.com/2009/12/09/using-self-tracking-entities-in-entity-framework-4-to-fix-the-error-the-object-could-not-be-added-or-attached/</link>
		<comments>http://jonshern.com/2009/12/09/using-self-tracking-entities-in-entity-framework-4-to-fix-the-error-the-object-could-not-be-added-or-attached/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 22:37:23 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[entity framework]]></category>

		<guid isPermaLink="false">http://jonshern.com/?p=215</guid>
		<description><![CDATA[Works with Entity Framework 4 CTP 2 and Visual Studio 2010 Beta 2
{&#34;The object could not be added or attached because its EntityReference has an EntityKey property value that does not match the EntityKey for this object.&#34;}
I am able to to insert the first record.
But subsequent records give the above error.
The structure is: Tasks have [...]]]></description>
			<content:encoded><![CDATA[<p>Works with Entity Framework 4 CTP 2 and Visual Studio 2010 Beta 2</p>
<p>{&quot;The object could not be added or attached because its EntityReference has an EntityKey property value that does not match the EntityKey for this object.&quot;}</p>
<p>I am able to to insert the first record.</p>
<p>But subsequent records give the above error.</p>
<p>The structure is: Tasks have Task Items. I am trying to save task items.</p>
<p>&nbsp;In this example my silverlight application is initiating this service call.<br />
	The task object is set by a dropdown on the client &nbsp;side.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> InsertTaskItem<span style="color: #000000;">&#40;</span>Task task, <span style="color: #FF0000;">string</span> value, DateTime dateTime<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            TaskItem taskItem <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TaskItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">Task</span> <span style="color: #008000;">=</span> task<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">TaskId</span> <span style="color: #008000;">=</span> task.<span style="color: #0000FF;">Id</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">OccurrenceTime</span> <span style="color: #008000;">=</span> dateTime<span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">CreatedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">ModifiedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">objectContext</span>.<span style="color: #0000FF;">AddToTaskItems</span><span style="color: #000000;">&#40;</span>taskItem<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">objectContext</span>.<span style="color: #0000FF;">SaveChanges</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>First Attempt Lets just atttach the object, it should be that easy right?</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> InsertTaskItem<span style="color: #000000;">&#40;</span>Task task, <span style="color: #FF0000;">string</span> value, DateTime dateTime<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            TaskItem taskItem <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TaskItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">Task</span> <span style="color: #008000;">=</span> task<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">TaskId</span> <span style="color: #008000;">=</span> task.<span style="color: #0000FF;">Id</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">OccurrenceTime</span> <span style="color: #008000;">=</span> dateTime<span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">CreatedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">ModifiedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
&nbsp;
            objectContext.<span style="color: #0000FF;">AttachTo</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>PracticeManager.<span style="color: #0000FF;">Server</span>.<span style="color: #0000FF;">Business</span>.<span style="color: #0000FF;">Data</span>.<span style="color: #0000FF;">PracticeModelContainer</span>.<span style="color: #0000FF;">TaskItem</span><span style="color: #008000;">&amp;</span>quot<span style="color: #008000;">;</span>, taskItem<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">objectContext</span>.<span style="color: #0000FF;">SaveChanges</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>
	I received the error.</p>
<pre>The provided EntitySet name must be qualified by the EntityContainer name, such as &#39;EntityContainerName.EntitySetName&#39;, or the DefaultContainerName property must be set for the ObjectContext.
Parameter name: entitySetName
</pre>
<p>I tried both the fully qualified type name, and the entity set name.</p>
<p>
	Since I am using .Net 4.0 and the Entity Framework,&nbsp; I realized I can use some of the POCO functionality they added to facilitate this specific scenario.</p>
<p>I can refactor and use Self Tracking Entities to accomplish my goal the right way.</p>
<p>The first step is download the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=13FDFCE4-7F92-438F-8058-B5B4041D0F01&amp;displaylang=en">Entity Framework 4 CTP 2</a>&nbsp; - It did not make it into VS 2010 Beta 2.</p>
<p>Navigate to your model, and Add New Code Generation Item.</p>
<p>Select ADO.NET Self Tracking Entity Generator.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> InsertTaskItem<span style="color: #000000;">&#40;</span>Task task, <span style="color: #FF0000;">string</span> value, DateTime dateTime<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            TaskItem taskItem <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TaskItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">Task</span> <span style="color: #008000;">=</span> task<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">TaskId</span> <span style="color: #008000;">=</span> task.<span style="color: #0000FF;">Id</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">OccurrenceTime</span> <span style="color: #008000;">=</span> dateTime<span style="color: #008000;">;</span>
&nbsp;
            taskItem.<span style="color: #0000FF;">CreatedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
            taskItem.<span style="color: #0000FF;">ModifiedTime</span> <span style="color: #008000;">=</span> DateTime.<span style="color: #0000FF;">Now</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
            <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>var context <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PracticeModelContainer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                context.<span style="color: #0000FF;">TaskItems</span>.<span style="color: #0000FF;">ApplyChanges</span><span style="color: #000000;">&#40;</span>taskItem<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                context.<span style="color: #0000FF;">SaveChanges</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Once I added the context save changes, the task item now save.</p>
<p>One problem is when setting the task property it is triggering the creation of a new entity, and then overwriting the foreign key with the key of the newly created task.</p>
<p>Once the line</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">taskItem.<span style="color: #0000FF;">Task</span> <span style="color: #008000;">=</span> task<span style="color: #008000;">;</span></pre></div></div>

<p>is commented out the save works as expected.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/12/09/using-self-tracking-entities-in-entity-framework-4-to-fix-the-error-the-object-could-not-be-added-or-attached/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF RIA and Server and Client Side Authentication</title>
		<link>http://jonshern.com/2009/12/06/wcf-ria-and-server-and-client-side-authentication/</link>
		<comments>http://jonshern.com/2009/12/06/wcf-ria-and-server-and-client-side-authentication/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 17:27:12 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/2009/12/06/wcf-ria-and-server-and-client-side-authentication/</guid>
		<description><![CDATA[Works with Silverlight 4.0 beta 1, Visual Studio 2010, and the Silverlight Business Application Template
&#160;
	In WCF Ria you can decorate your service methods with the
[RequiresAuthentication] attribute to denote the user must be authenticated.
This comes from the System.Web.DomainServices namespace.
This same functionality is not available on the client side.
One method is to pop the login form when [...]]]></description>
			<content:encoded><![CDATA[<p>Works with Silverlight 4.0 beta 1, Visual Studio 2010, and the Silverlight Business Application Template</p>
<p>&nbsp;<br />
	In WCF Ria you can decorate your service methods with the</p>
<p>[RequiresAuthentication] attribute to denote the user must be authenticated.</p>
<p>This comes from the System.Web.DomainServices namespace.</p>
<p>This same functionality is not available on the client side.</p>
<p>One method is to pop the login form when a user navigates to a restricted page.</p>
<p>I am not using roles, but you could just as easily use IsInRole(string role) instead.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnNavigatedTo<span style="color: #000000;">&#40;</span>NavigationEventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            LoginUI.<span style="color: #0000FF;">LoginRegistrationWindow</span> loginWindow <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LoginUI.<span style="color: #0000FF;">LoginRegistrationWindow</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>WebContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">IsAuthenticated</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                loginWindow.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            serviceClient.<span style="color: #0000FF;">GetTasksAsync</span><span style="color: #000000;">&#40;</span>WebContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>The user can still see that the page exists.</p>
<p>In order to hide the page you can use the events from WebContext.Current.Authentication</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">public</span> MainPage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            InitializeComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
&nbsp;
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">loginContainer</span>.<span style="color: #0000FF;">Child</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LoginStatus<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            WebContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Authentication</span>.<span style="color: #0000FF;">LoggedIn</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventHandler</span><span style="color: #008000;">&lt;</span><span style="color: #000000;">system</span>.<span style="color: #0000FF;">windows</span>.<span style="color: #0000FF;">ria</span>.<span style="color: #0000FF;">applicationservices</span>.<span style="color: #0000FF;">authenticationeventargs</span><span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>Authentication_LoggedIn<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            WebContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Authentication</span>.<span style="color: #0000FF;">LoggedOut</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventHandler</span><span style="color: #008000;">&lt;</span><span style="color: #000000;">system</span>.<span style="color: #0000FF;">windows</span>.<span style="color: #0000FF;">ria</span>.<span style="color: #0000FF;">applicationservices</span>.<span style="color: #0000FF;">authenticationeventargs</span><span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>Authentication_LoggedOut<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            ManageMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #0600FF;">void</span> Authentication_LoggedOut<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Ria</span>.<span style="color: #0000FF;">ApplicationServices</span>.<span style="color: #0000FF;">AuthenticationEventArgs</span> e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            ManageMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">void</span> Authentication_LoggedIn<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Ria</span>.<span style="color: #0000FF;">ApplicationServices</span>.<span style="color: #0000FF;">AuthenticationEventArgs</span> e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            ManageMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> ManageMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span>WebContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">User</span>.<span style="color: #0000FF;">IsAuthenticated</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                dashboardDivider.<span style="color: #0000FF;">Visibility</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Visibility</span>.<span style="color: #0000FF;">Collapsed</span><span style="color: #008000;">;</span>
                dashboardLink.<span style="color: #0000FF;">Visibility</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Visibility</span>.<span style="color: #0000FF;">Collapsed</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0600FF;">else</span>
            <span style="color: #000000;">&#123;</span>
                dashboardDivider.<span style="color: #0000FF;">Visibility</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Visibility</span>.<span style="color: #0000FF;">Visible</span><span style="color: #008000;">;</span>
                dashboardLink.<span style="color: #0000FF;">Visibility</span> <span style="color: #008000;">=</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Windows</span>.<span style="color: #0000FF;">Visibility</span>.<span style="color: #0000FF;">Visible</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #008000;">&lt;/</span><span style="color: #000000;">system</span>.<span style="color: #0000FF;">windows</span>.<span style="color: #0000FF;">ria</span>.<span style="color: #0000FF;">applicationservices</span>.<span style="color: #0000FF;">authenticationeventargs</span><span style="color: #008000;">&gt;&lt;/</span><span style="color: #000000;">system</span>.<span style="color: #0000FF;">windows</span>.<span style="color: #0000FF;">ria</span>.<span style="color: #0000FF;">applicationservices</span>.<span style="color: #0000FF;">authenticationeventargs</span><span style="color: #008000;">&gt;</span></pre></div></div>

<p>
	&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/12/06/wcf-ria-and-server-and-client-side-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF Ria Authentication and SqlMembershipProvider</title>
		<link>http://jonshern.com/2009/12/02/wcf-ria-authentication-and-sqlmembershipprovider/</link>
		<comments>http://jonshern.com/2009/12/02/wcf-ria-authentication-and-sqlmembershipprovider/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 06:40:02 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/2009/12/02/wcf-ria-authentication-and-sqlmembershipprovider/</guid>
		<description><![CDATA[&#160;
Getting the Authentication working is a snap, if you remember how to specify the connection string for the SqlMembershipProvider.
&#160;
I had forgotten.
So it was back to Asp.net 2.0 even though I have an Application built with Silverlight 4.0.
Since WCF RIA Authentication uses the membership provider, and now the web.config is greatly simplified.
The default membership stuff is [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Getting the Authentication working is a snap, if you remember how to specify the connection string for the SqlMembershipProvider.</p>
<p>&nbsp;</p>
<p>I had forgotten.</p>
<p>So it was back to Asp.net 2.0 even though I have an Application built with Silverlight 4.0.</p>
<p>Since WCF RIA Authentication uses the membership provider, and now the web.config is greatly simplified.</p>
<p>The default membership stuff is not in there anymore.</p>
<p>&nbsp;</p>
<p>If you are using the SqlMembershipProvider don&#39;t forget to add the provider configuration in your web.config.</p>
<p>After you run aspnet_regsql of course<span style="font-family: wingdings">J</span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">add<span style="color: blue"> <span style="color: red">name<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeModelUsers</span>&quot;<span style="color: blue"> <span style="color: red">type<span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>&quot;<span style="color: blue"> <span style="color: red">applicationName<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeManager</span>&quot;<span style="color: blue"> <span style="color: red">connectionStringName<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeModel</span>&quot;<span style="color: blue"> /&gt;</span> </span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">roleManager<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">membership<span style="color: blue"> <span style="color: red">defaultProvider<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeManagerUserProvider</span>&quot;<span style="color: blue">&gt;</span> </span></span></span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">add<span style="color: blue"> <span style="color: red">name<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeManagerUserProvider</span>&quot;<span style="color: blue"> <span style="color: red">type<span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>&quot;<span style="color: blue"> <span style="color: red">applicationName<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeManager</span>&quot;<span style="color: blue"> <span style="color: red">connectionStringName<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeModel</span>&quot;<span style="color: blue"> <span style="color: red">enablePasswordReset<span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> <span style="color: red">enablePasswordRetrieval<span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> <span style="color: red">passwordFormat<span style="color: blue">=</span>&quot;<span style="color: blue">Clear</span>&quot;<span style="color: blue"> <span style="color: red">requiresQuestionAndAnswer<span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> <span style="color: red">requiresUniqueEmail<span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> /&gt;</span> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">membership<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">profile<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">properties<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">add<span style="color: blue"> <span style="color: red">name<span style="color: blue">=</span>&quot;<span style="color: blue">FriendlyName</span>&quot;<span style="color: blue"> /&gt;</span> </span></span></span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">properties<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;<span style="color: #a31515">add<span style="color: blue"> <span style="color: red">name<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeProfileProvider</span>&quot;<span style="color: blue"> <span style="color: red">type<span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span>&quot;<span style="color: blue"> <span style="color: red">applicationName<span style="color: blue">=</span>&quot;<span style="color: blue">Practice Manager</span>&quot;<span style="color: blue"> <span style="color: red">connectionStringName<span style="color: blue">=</span>&quot;<span style="color: blue">PracticeModel</span>&quot;<span style="color: blue"> /&gt;</span> </span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">providers<span style="color: blue">&gt;</span> </span></span></p>
<p><span style="font-family: consolas; color: blue; font-size: 9pt">&lt;/<span style="color: #a31515">profile<span style="color: blue">&gt;</span></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/12/02/wcf-ria-authentication-and-sqlmembershipprovider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework and Sql Server Database Projects</title>
		<link>http://jonshern.com/2009/11/25/entity-framework-and-sql-server-database-projects/</link>
		<comments>http://jonshern.com/2009/11/25/entity-framework-and-sql-server-database-projects/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 00:36:47 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/?p=195</guid>
		<description><![CDATA[Entity Framework 4 adds a bunch of new features this time around.
One of which is to push model changes back to the database.
If you are using one of the Database projects included in the Database Edition you may wonder how you are going to bridge the gap between the two projects.
Unfortunately there is no good [...]]]></description>
			<content:encoded><![CDATA[<p>Entity Framework 4 adds a bunch of new features this time around.<br />
One of which is to push model changes back to the database.</p>
<p>If you are using one of the Database projects included in the Database Edition you may wonder how you are going to bridge the gap between the two projects.</p>
<p>Unfortunately there is no good way to do this.<br />
Right now MS is prescribing to generate alter scripts from the EDMX model and add as a script to the database project.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/25/entity-framework-and-sql-server-database-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acceptance Test Engineering Guidance</title>
		<link>http://jonshern.com/2009/11/23/acceptance-test-engineering-guidance/</link>
		<comments>http://jonshern.com/2009/11/23/acceptance-test-engineering-guidance/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 18:59:30 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/?p=197</guid>
		<description><![CDATA[The Patterns and Practices team at Microsoft has just released a guide to engineering acceptance tests.

Some things that are covered.
How to Plan for Acceptance Testing
What Kinds of Acceptance Tests to Run
How to Create and Run Acceptance Tests
Defining What “Done” Means
How to Justify Your Approach

It is book both for someone creating a testing plan, and the [...]]]></description>
			<content:encoded><![CDATA[<p>The Patterns and Practices team at Microsoft has just released a guide to engineering acceptance tests.</p>
<ul>
<li>Some things that are covered.</li>
<li>How to Plan for Acceptance Testing</li>
<li>What Kinds of Acceptance Tests to Run</li>
<li>How to Create and Run Acceptance Tests</li>
<li>Defining What “Done” Means</li>
<li>How to Justify Your Approach</li>
</ul>
<p>It is book both for someone creating a testing plan, and the person actually writing the tests.</p>
<p><a href="http://testingguidance.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=35058#DownloadId=89573">Get it now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/23/acceptance-test-engineering-guidance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fishbowl &#8211; Facebook in a whole new light</title>
		<link>http://jonshern.com/2009/11/22/fishbowl-facebook-in-a-whole-new-light/</link>
		<comments>http://jonshern.com/2009/11/22/fishbowl-facebook-in-a-whole-new-light/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 07:02:47 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/2009/11/22/fishbowl-facebook-in-a-whole-new-light/</guid>
		<description><![CDATA[Recently I was at PDC.
Several talks used the application
Fishbowl as the subject of their demo.
It is a showcase of some really nice technologies, but more importantly it is a great way to interact with facebook.
Go out and download it, it is free.
]]></description>
			<content:encoded><![CDATA[<p>Recently I was at PDC.</p>
<p>Several talks used the application<br />
<a href="http://www.fishbowlclient.com/">Fishbowl </a>as the subject of their demo.</p>
<p>It is a showcase of some really nice technologies, but more importantly it is a great way to interact with facebook.<br />
Go out and download it, it is free.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/22/fishbowl-facebook-in-a-whole-new-light/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More information on XAML Toolkit CTP</title>
		<link>http://jonshern.com/2009/11/21/more-information-on-xaml-toolkit-ctp/</link>
		<comments>http://jonshern.com/2009/11/21/more-information-on-xaml-toolkit-ctp/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 16:53:26 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/?p=191</guid>
		<description><![CDATA[Micheal  Shim has some really good information regarding what is in the CTP.
http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/
]]></description>
			<content:encoded><![CDATA[<p>Micheal  Shim has some really good information regarding what is in the CTP.<br />
<a href="http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/">http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/21/more-information-on-xaml-toolkit-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft XAML Toolkit and XamlDom released</title>
		<link>http://jonshern.com/2009/11/19/microsoft-xaml-toolkit-and-xamldom-released/</link>
		<comments>http://jonshern.com/2009/11/19/microsoft-xaml-toolkit-and-xamldom-released/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 23:56:51 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/2009/11/19/microsoft-xaml-toolkit-and-xamldom-released/</guid>
		<description><![CDATA[Today the XAML team announced the availability of the Microsoft XAML Toolkit
http://code.msdn.microsoft.com/XAML
It has been taken down due to signing issues, but will be back soon.
This will allow many things 

A Dom representation of the Xaml control tree.
Use Linq against the XamlDom, similar to XLinq for XDocument
It is going to be very useful for tools like [...]]]></description>
			<content:encoded><![CDATA[<p>Today the XAML team announced the availability of the <a href="http://code.msdn.microsoft.com/XAML">Microsoft XAML Toolkit</a><br />
http://code.msdn.microsoft.com/XAML</p>
<p>It has been taken down due to signing issues, but will be back soon.</p>
<p>This will allow many things </p>
<ul>
A Dom representation of the Xaml control tree.<br />
Use Linq against the XamlDom, similar to XLinq for XDocument<br />
It is going to be very useful for tools like XAML Designers or Static Analysis.<br />
We can also do some XamlDom functional construction.</ul>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/19/microsoft-xaml-toolkit-and-xamldom-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PLinq Performance Tip</title>
		<link>http://jonshern.com/2009/11/19/plinq-performance-tip/</link>
		<comments>http://jonshern.com/2009/11/19/plinq-performance-tip/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 19:33:18 +0000</pubDate>
		<dc:creator>Jon Shern</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://jonshern.com/?p=187</guid>
		<description><![CDATA[When using PLinq
Memory Allocations can be the bottleneck.
Anonomous types/reference types are allocated on the heap and will have to be garbage collected.
The garbage collector was designed with low latency/fast UI thread design considerations.
Try to use value types.
Or in the app.config add

  

This enables server mode garbage collection.
Typically workstation mode  gc is the fastest, [...]]]></description>
			<content:encoded><![CDATA[<p>When using PLinq<br />
Memory Allocations can be the bottleneck.</p>
<p>Anonomous types/reference types are allocated on the heap and will have to be garbage collected.<br />
The garbage collector was designed with low latency/fast UI thread design considerations.<br />
Try to use value types.<br />
Or in the app.config add<br />
<runtime><br />
  <<a href="http://msdn.microsoft.com/en-us/library/ms229357.aspx">gcserver </a>enabled="true"/><br />
</runtime></p>
<p>This enables server mode garbage collection.<br />
Typically workstation mode  gc is the fastest, but when we deal with parellism and garbage collection across multiple processors server garbage collection can reap significant performance improvements.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonshern.com/2009/11/19/plinq-performance-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
