<?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>The other side of complexity</title>
	<atom:link href="http://condron.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://condron.wordpress.com</link>
	<description>Simplicy in Software Design and Code</description>
	<lastBuildDate>Sun, 03 Jan 2010 06:32:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='condron.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The other side of complexity</title>
		<link>http://condron.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://condron.wordpress.com/osd.xml" title="The other side of complexity" />
	<atom:link rel='hub' href='http://condron.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Request Entity Pattern or &#8216;CRM Wizards&#8217;</title>
		<link>http://condron.wordpress.com/2010/01/01/request-entity-pattern-or-crm-wizards/</link>
		<comments>http://condron.wordpress.com/2010/01/01/request-entity-pattern-or-crm-wizards/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 04:12:42 +0000</pubDate>
		<dc:creator>Chris Condron</dc:creator>
				<category><![CDATA[CRM Dynamics]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[4.0]]></category>
		<category><![CDATA[Request Entity Pattern]]></category>

		<guid isPermaLink="false">http://condron.wordpress.com/?p=15</guid>
		<description><![CDATA[This pattern has proven to be tremendously useful in a number of situations so I thought I'd take a few minutes to walk through it. Primarily it provides an easy way to deal with onetime setup logic or constraints without making the target entity overly complicated. You in effect have a custom form just for the create and it also provides a number of extra injection points for plugins, JavaScript, and duplicate detection outside of the main entity. Finally it gives a built-in audit trail of each create request for key entities.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=15&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a number of  places in our CRM application we need to ensure that certain rules and conditions are met before allowing the creation of certain entities, primarily adding new accounts, long story. We also wanted to avoid creating custom aspx web pages to keep the deployment and maintenance simple as well, even longer story.</p>
<p>To solve this problem we eventually settled on a Request Entity Pattern where we gave users an AccountRequest entity with a small number of attributes that fires a server-side plug-in to create the account. Then some JavaScript in the request entity opens the newly created account and closes the request.</p>
<p>This pattern has proven to be tremendously useful in a number of situations so I thought I&#8217;d take a few minutes to walk through it. Primarily it provides an easy way to deal with onetime setup logic or constraints without making the target entity overly complicated. You in effect have a custom form just for the create and it also provides a number of extra injection points for plugins, JavaScript, and duplicate detection outside of the main entity. Finally it gives a built-in audit trail of each create request for key entities.</p>
<p>Example of an Request Entity Pattern for Account:</p>
<ol>
<li>Create a new custom entity Account Request, add attributes for the required fields on account and any others needed for account setup. Make sure that required fields on Account are also marked required on the Request entity. Add an N-to-1 relationship between AccountRequest and Account named LinkedAccount.  (You want a lookup field on the account form names LinkedAccount with the id of the Account in it.)</li>
<li> Remove the create security permission for the account entity from the users, add security permissions for create and update permissions to the new AccountRequest entity.</li>
<li> Add an ISV Button to the Account View called &#8216;New&#8217; that opens a new AccountRequest. (The original new button will be hidden by security.)</li>
<li> Add java script on the AccountRequest to
<ol>
<li>set the LinkedAccount attribute forcesubmit = true.</li>
<li>check if the value in LinkedAccount, if it is not null open the linked account in a new window and close the request form. </li>
</ol>
</li>
<li>Create a plugin for AccountRequest
<ol>
<li>Register Pre-Stage of the parent pipeline for Create and Update, and use the false option on the CreateCrmService to run in the system context, (the user does not have privileges to create an account.)</li>
<li>If the business conditions are met then create the new account, update the account lookup attribute in the target property bag with the ID of the new account, and set the owner of the account to the user, (it will default to SYSTEM.) The forcesubmit in step 4 above ensures the account lookup attribute will be in the property bag.</li>
</ol>
</li>
<li>Add custom business logic and duplicate detection as required to the AccountRequest Entity.</li>
</ol>
<p> Chris Condron</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/condron.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/condron.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/condron.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=15&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://condron.wordpress.com/2010/01/01/request-entity-pattern-or-crm-wizards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7f3abc9de1c7aea50b3d997f578d08f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chris Condron</media:title>
		</media:content>
	</item>
		<item>
		<title>Duplicate Detection: too much of a good thing.</title>
		<link>http://condron.wordpress.com/2010/01/01/duplicate-detection-too-much-of-a-good-thing/</link>
		<comments>http://condron.wordpress.com/2010/01/01/duplicate-detection-too-much-of-a-good-thing/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 02:59:40 +0000</pubDate>
		<dc:creator>Chris Condron</dc:creator>
				<category><![CDATA[CRM Dynamics]]></category>
		<category><![CDATA[4.0]]></category>
		<category><![CDATA[Duplicate Detection]]></category>

		<guid isPermaLink="false">http://condron.wordpress.com/?p=12</guid>
		<description><![CDATA[I found a defect working on the CRM server today.  We recently added the duplicate detection rules to prevent adding new duplicate records and now every time I change anything on my ACME test account there is a duplicate warning about its subsidiary having the same name (ACME Widgets.) As the intention is to only [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=12&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found a defect working on the CRM server today.  We recently added the duplicate detection rules to prevent adding new duplicate records and now every time I change anything on my ACME test account there is a duplicate warning about its subsidiary having the same name (ACME Widgets.) As the intention is to only check when new records are added this is (for our project) a bug.</p>
<p> The duplicate rules always fire on both create and update, and all of the conditions are OR based so there is no way to filter them out by status or other flags to indicate that this record has been reviewed &amp; should no longer be checked. This gets really annoying when you are updating something completely unrelated and have to click though a duplicate warning again and again.</p>
<p>So to the fix, it is based on two elements 1) CRM allows you to duplicate check against different types of entities. and 2) We are also using a &#8220;helper&#8221; entity in the creation of our accounts called AccountRequest. (This helper is an entity with 4 or 5 attributes that collects the key information to create an account and then uses a server-side plugin to create the account entity. When the form updates a piece of JavaScript opens the new Account for the user, giving them in effect a wizard to create new accounts. I can post details if people are interested.)</p>
<p> So what we do is run duplicate detection job between the AccountRequest entity and the Account entity. This will alert the user to potential duplicate new accounts and but will not run when the account is updated.</p>
<p>Problem solved.</p>
<p>We can even extend it with the soundex solution <a title="here" href="http://advantageworks.blogspot.com/2008/01/extending-duplicate-detection-with.html" target="_blank">here</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/condron.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/condron.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/condron.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=12&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://condron.wordpress.com/2010/01/01/duplicate-detection-too-much-of-a-good-thing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7f3abc9de1c7aea50b3d997f578d08f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chris Condron</media:title>
		</media:content>
	</item>
		<item>
		<title>Development and Documentation</title>
		<link>http://condron.wordpress.com/2008/02/24/development-and-documentation/</link>
		<comments>http://condron.wordpress.com/2008/02/24/development-and-documentation/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 19:26:07 +0000</pubDate>
		<dc:creator>Chris Condron</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Process]]></category>

		<guid isPermaLink="false">http://condron.wordpress.com/2008/02/24/development-and-documentation/</guid>
		<description><![CDATA[I started writing my about page and it turned into a post. It stared with this: I am a Sr Architect currently leading the QA Architecture domain for a regional insurance company. I have been writing code for about 25 years. I&#8217;ve been writing code professionally for about 15. I have been designing and creating custom [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=7&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I started writing my about page and it turned into a post.</p>
<p>It stared with this:</p>
<p>I am a Sr Architect currently leading the QA Architecture domain for a regional insurance company. I have been writing code for about 25 years. I&#8217;ve been writing code professionally for about 15. I have been designing and creating custom enterprise automation solutions and frameworks for fortune 500 companies for about 10 years.</p>
<p>I also have founded or been a founding member of several small technology and consulting companies. These range from, teaching Chess to troubled youth; Restaurants (never achieved funding); Web Hosting; Custom Telecom Testing and Certification Solutions; and Online Music Sales.</p>
<p>And here is the post</p>
<p>As enterprise QA solutions (good ones at least) are tightly coupled to the SDLC I have also become involved with development process, design for test and standards.  My current beliefs on process and documentation is that there is an inverse relationship between, team connectivity and communication; and the need for formal documentation. i.e. for a small tight team, go agile, no docs all talk. for large dispersed team standards. process and docs are a must to succeed. My basic approach is to advocate lightweight and effective documentation. It should be easy to produce and contain thing people need to know. This also means that if you can&#8217;t hire a small team of quality developers to complete the project you need to spend some time thinking about how all of your docs work together.</p>
<p>Basically, treat you documentation and process as you would a software project, architect it and only create what you need.</p>
<p>Conceptually one can think of a software project as a writing exercise. Consider a project using a theoretical process in a large company:</p>
<p>Someone in the business gets and idea.</p>
<ol>
<li>
<div>They write an email and see if people like the idea.</div>
</li>
<li>
<div>They write a charter document detailing the concept and what is in and out of scope for other business people to decide if they want it and get some idea of how much that would cost.</div>
</li>
<li>
<div>Then they bring in the BAs to write a business requirements version of the idea detailing all the things this project would do for the business</div>
</li>
<li>
<div>Next the Architecure staff writes a technical version of the idea talking about how this would work.</div>
</li>
<li>
<div>Meanwhile the BAs write a feature requirements document detailing the changes to the systems that would produce the required effects.</div>
</li>
<li>
<div>Now the development team writes a techinical document on how to write code to make the systems procude the changes the BAs have requested.</div>
</li>
<li>
<div>Finally some of the developers write code that the machines read to produce the desired effects.</div>
</li>
<li>
<div>During all of this QA is writing up notes on where and how all of these documents and code don’t agree, and making people go back and rethink and change what they wrote.</div>
</li>
</ol>
<p>The code in effect is the final draft of a techincal paper. Formal process say all of the drafts are writen to standards by different groups. Agile process says focus on the final draft and make all of your changes there.</p>
<p>The basic problem all of this is addressing is that the entirety of the conceptual model for a software project quickly becomes to big for any one person to hold in their head. As soon as you need to share the model with a second person you have a problem. There are so many details and aspects of the project that interconnect and cross impact that you can’t even just put it in one document.</p>
<p>In agile you build a shared mindset and set of assumtions that you keep current through constant communication. Good for small teams, hard to share to larger less connected groups.</p>
<p>In formal proccess you publish standards and walk through a know proccess and series of documents. More overhead, but scales much better for large loosly connected groups.</p>
<p>Good process and architecture addresses the core issue of complexity in the conceptual model through a number of appraoches. I think <a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215">Domain-Driven Design </a>by Evans is a tour-de-force on the subject. Model clarity, separtion of domains, and the ubiquetous language to link the levels in the process stack are all wonderfull ways to make everything work much better.</p>
<p>More on this later.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/condron.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/condron.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/condron.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/condron.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/condron.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=7&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://condron.wordpress.com/2008/02/24/development-and-documentation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7f3abc9de1c7aea50b3d997f578d08f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chris Condron</media:title>
		</media:content>
	</item>
		<item>
		<title>Blogging Code</title>
		<link>http://condron.wordpress.com/2008/02/24/blogging-code/</link>
		<comments>http://condron.wordpress.com/2008/02/24/blogging-code/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 07:17:17 +0000</pubDate>
		<dc:creator>Chris Condron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://condron.wordpress.com/2008/02/24/blogging-code/</guid>
		<description><![CDATA[I found out how to blog code snippets here &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=6&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found out how to blog code snippets <a href="http://blogs.msdn.com/noahc/archive/2006/07/06/658458.aspx#7454989">here</a></p>
<p>&nbsp;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/condron.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/condron.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/condron.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/condron.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/condron.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=6&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://condron.wordpress.com/2008/02/24/blogging-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7f3abc9de1c7aea50b3d997f578d08f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chris Condron</media:title>
		</media:content>
	</item>
		<item>
		<title>Detached Data in DLinq</title>
		<link>http://condron.wordpress.com/2008/02/24/detached-data-in-dlinq/</link>
		<comments>http://condron.wordpress.com/2008/02/24/detached-data-in-dlinq/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 06:55:43 +0000</pubDate>
		<dc:creator>Chris Condron</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[DLinQ]]></category>

		<guid isPermaLink="false">http://condron.wordpress.com/2008/02/24/detached-data-in-dlinq/</guid>
		<description><![CDATA[Update: before trying the code pattern here,  see if you can use this  instead. - Chris I was reading two good blogs about Linq to SQL and ASP.Net applications  here and here. Based on the pattern set up by Rocky Moore (see first link) I came up with this code. Using generics and a little bit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=5&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> before trying the code pattern here,  see if you can use <a title="this" href="http://msdn.microsoft.com/en-us/library/ee807305(VS.91).aspx" target="_blank">this </a> instead.</p>
<p>- Chris</p>
<p>I was reading two good blogs about Linq to SQL and ASP.Net applications  <a href="http://www.rockymoore.com/TheCoder/archive/2007/11/03/LINQ_Disconnected_Attach_no_Change_tracking_fix.aspx">here</a> and <a href="http://west-wind.com/weblog/posts/135659.aspx">here</a>.</p>
<p>Based on the pattern set up by Rocky Moore (see first link) I came up with this code. Using generics and a little bit of reflection in a base class.</p>
<p>Here is the base class</p>
<div style="background:#f3f3f3;border:windowtext 1pt solid;padding:6pt 4pt;">
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">detachableEntity</span>&lt;T&gt; <span style="color:blue;">where</span> T : <span style="color:#2b91af;">detachableEntity</span>&lt;T&gt;, <span style="color:blue;">new</span>()</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> <span style="color:blue;">void</span> OnDataLoaded()</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         original = Clone();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> T original { <span style="color:blue;">get</span>; <span style="color:blue;">set</span>; }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> T Copy()</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">return</span> Copy((T)<span style="color:blue;">this</span>);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> <span style="color:blue;">static</span> T Copy(T Old)</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         T newItem = Clone(Old);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         newItem.OnDataLoaded(); <span style="color:green;">// set the original state for the new object to the currect state </span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">return</span> newItem;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> T Clone()</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">return</span> Clone((T)<span style="color:blue;">this</span>);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">public</span> <span style="color:blue;">static</span> T Clone(T item)</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">if</span> (item == <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">            <span style="color:blue;">return</span> <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         T newItem = <span style="color:blue;">new</span> T();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:green;">// copy all subclass properties.</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">foreach</span><span style="color:#0000ff;"> </span>(<span style="color:#2b91af;">PropertyInfo</span><span style="color:#2b91af;"> </span>prop <span style="color:blue;">in</span> item.GetType().GetProperties())</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">            <span style="color:#2b91af;">PropertyInfo</span> prop2 = item.GetType().GetProperty(prop.Name);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">            prop2.SetValue(newItem, prop.GetValue(item, <span style="color:blue;">null</span>), <span style="color:blue;">null</span>);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:green;">//the two items now share the same orginal state object, fix this by </span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:green;">//cloning the original state object on the item that to create a new original state</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:green;">//object for the new item</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">if</span> (item.original != <span style="color:blue;">null</span>)</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">            newItem.original = item.original.Clone();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">         <span style="color:blue;">return</span> newItem;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;margin:0 0 10pt;padding:0;"><span style="font-size:10pt;line-height:115%;font-family:'Courier New';">   }</span></p>
</div>
<p>In the partial classes created by Linq Designer here is how to add the base class</p>
<p>As the pattern is fixed, it is a good candidate for replace all in the partial class file.</p>
<div style="background:#f3f3f3;border:windowtext 1pt solid;padding:6pt 4pt;">
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:blue;">partial</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">Address</span> : <span style="color:#2b91af;">detachableEntity</span>&lt;<span style="color:#2b91af;">Address</span>&gt;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:blue;">partial</span> <span style="color:blue;">void</span> OnLoaded() { <span style="color:blue;">base</span>.OnDataLoaded(); }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   }</span></p>
</div>
<p>and a usage example</p>
<div style="background:#f3f3f3;border:windowtext 1pt solid;padding:6pt 4pt;">
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;color:blue;font-family:'Courier New';">static</span><span style="font-size:10pt;font-family:'Courier New';"> <span style="color:blue;">void</span> Main(<span style="color:blue;">string</span>[] args)</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">{</span></p>
<p class="MsoNormal" style="background:#f3f3f3;text-indent:.5in;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;color:green;font-family:'Courier New';">//Create new Entity</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:#2b91af;">Address</span> home = <span style="color:blue;">new</span> <span style="color:#2b91af;">Address</span>();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Create new data context</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:#2b91af;">AdventureWorksDataContext</span> AW = <span style="color:blue;">new</span> <span style="color:#2b91af;">AdventureWorksDataContext</span>();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Get Data</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   home = AW.Addresses.First();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">// Disconnect Data Context</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Modify Data</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   home.City = home.City + <span style="color:#a31515;">&#8220;AAA&#8221;</span>;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">// New Data context</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW = <span style="color:blue;">new</span> <span style="color:#2b91af;">AdventureWorksDataContext</span>();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Attach Entity</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW.Addresses.Attach(home, home.original);</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Review Changes</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:#2b91af;">ChangeSet</span> Changes = AW.GetChangeSet();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Update Data Source</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW.SubmitChanges();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Dispose Data Context</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW.Dispose();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   AW = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Dispose Entity</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   home = <span style="color:blue;">null</span>;</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';"> </span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:green;">//Create new Data Context </span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   <span style="color:blue;">using</span> (AW = <span style="color:blue;">new</span> <span style="color:#2b91af;">AdventureWorksDataContext</span>())</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   {</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:green;">//Create new Entity</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:#2b91af;">Address</span> NewHome = AW.Addresses.FirstOrDefault(addr =&gt; addr.City.Contains(<span style="color:#a31515;">&#8220;AAA&#8221;</span>));</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:green;">//Modify Data (remove earlier changes)</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      NewHome.City = NewHome.City.TrimEnd(<span style="color:blue;">new</span> <span style="color:blue;">char</span>[] { <span style="color:#a31515;">&#8216;A&#8217;</span> });</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      <span style="color:green;">//Submit Changes in the same context</span></span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">      AW.SubmitChanges();</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">   }</span></p>
<p class="MsoNormal" style="background:#f3f3f3;line-height:normal;margin:0;padding:0;"><span style="font-size:10pt;font-family:'Courier New';">}</span></p>
</div>
<p>This should be quite useful for detached applications.</p>
<p>-Chris</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/condron.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/condron.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/condron.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/condron.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/condron.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=condron.wordpress.com&amp;blog=2963037&amp;post=5&amp;subd=condron&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://condron.wordpress.com/2008/02/24/detached-data-in-dlinq/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a7f3abc9de1c7aea50b3d997f578d08f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Chris Condron</media:title>
		</media:content>
	</item>
	</channel>
</rss>
