<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The MossyBlog Times Archives 2007 - 2009 : MVC</title><link>http://blogs.msdn.com/msmossyblog/archive/tags/MVC/default.aspx</link><description>Tags: MVC</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>LINQ to SQL – Poormans DAO / CRUD.</title><link>http://blogs.msdn.com/msmossyblog/archive/2009/01/11/linq-to-sql-poormans-dao-crud.aspx</link><pubDate>Sun, 11 Jan 2009 11:26:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9305533</guid><dc:creator>scbarnes</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/msmossyblog/comments/9305533.aspx</comments><wfw:commentRss>http://blogs.msdn.com/msmossyblog/commentrss.aspx?PostID=9305533</wfw:commentRss><wfw:comment>http://blogs.msdn.com/msmossyblog/rsscomments.aspx?PostID=9305533</wfw:comment><description>&lt;p&gt;I’m an extremely lazy coder. If i can find a way to write a base class to do the bulk of my chores within code, by crikey I'll do it and damn the scorn from my peers.&lt;/p&gt;  &lt;p&gt;In this case, I wanted to write fairly generic CRUD (Create, Read, Update &amp;amp; Delete) methods using LINQ to SQL. The rationale as to why I wanted to do this was simply due to the fact that LINQ to SQL already takes care of writing the various Entity Classes properties – so - &lt;em&gt;why do I still need to tease out each field name to do an Update or Select?&lt;/em&gt; &lt;/p&gt;  &lt;p&gt;The other reason I came up with this as I had some issues with UPDATE in LINQ to SQL (mainly due to having relational tables), basically i was breaking the “&lt;a href="http://martinfowler.com/eaaCatalog/unitOfWork.html" target="_blank"&gt;unit of work&lt;/a&gt;” pattern and blaming LINQ to SQL for not doing what I thought its job should be&lt;em&gt; (I'm sure I'll bend the ear of the LINQ team on what I think the right approach should be hehe).&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Here is my cheat source on how to get out of actually doing work.&lt;/p&gt;  &lt;h2&gt;The BaseDAO.&lt;/h2&gt;  &lt;p&gt;This class is where you’ll inherit all your DAO classes from here on out (should you buy into my code wisdom). I’ve kept the methods as generic as possible and the tax you pay for doing this is that the execution time will grow by a few ms (my tests found it not noticeable).&lt;/p&gt;  &lt;p&gt;When firing your &lt;strong&gt;Update, Create, Delete&lt;/strong&gt; &amp;amp; &lt;strong&gt;Read&lt;/strong&gt; methods, you simply pass in your proposed entity to persist as well as the &lt;strong&gt;DataContext&lt;/strong&gt; in which you wish to use. I’m not thrilled at passing &lt;strong&gt;DataContexts&lt;/strong&gt; around in arguments but in this case I couldn’t think of an alternative approach.&lt;/p&gt;  &lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 433px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 281px; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  1: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  2: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.Linq;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  3: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.Linq.Mapping;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  4: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Linq;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  5: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Reflection;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  6: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  7: &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; JARVIS.Lib.DAL
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  8: {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  9:     &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 10:     &lt;span style="color: #808080"&gt;/// Base Data Access Object&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 11:     &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 12:     &lt;span style="color: #808080"&gt;/// &amp;lt;remarks&amp;gt;TODO:&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 13:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; BaseDAO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 14:     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 15:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 16:         &lt;span style="color: #808080"&gt;/// Update an Entity Row in the LINQ Context.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 17:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 18:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Update&amp;lt;T&amp;gt;(T entity, DataContext db) where T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 19:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 20:             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (db)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 21:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 22:                 Table&amp;lt;T&amp;gt; table = db.GetTable&amp;lt;T&amp;gt;();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 23:                 T original = table.FirstOrDefault(e =&amp;gt; e == entity);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 24:                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (original != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 25:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 26:                     var model = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AttributeMappingSource().GetModel(db.GetType());
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 27:                     MetaTable tbl = model.GetTable(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(T));
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 28:                     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var dm &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; tbl.RowType.DataMembers)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 29:                     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 30:                         PropertyInfo p1 = original.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 31:                         PropertyInfo p2 = entity.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 32:                         &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 33:                         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 34:                             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (p1.PropertyType.ToString() != &amp;quot;&lt;span style="color: #8b0000"&gt;System.DateTime&lt;/span&gt;&amp;quot;)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 35:                             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 36:                                 p1.SetValue(original, p2.GetValue(entity, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 37:                             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 38:                             &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 39:                             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 40:                                 &lt;span style="color: #008000"&gt;// *** WARNING: Cheesy Hack : WARNING ***&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 41:                                 &lt;span style="color: #008000"&gt;//                                &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 42:                                 &lt;span style="color: #008000"&gt;// Just in case you have a row that doesn't have DateTime Set..&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 43:                                 &lt;span style="color: #008000"&gt;// This will hack your way past an exception. Highly recommend&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 44:                                 &lt;span style="color: #008000"&gt;// you ensure your data going into the DB is validated against&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 45:                                 &lt;span style="color: #008000"&gt;// DB rules.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 46:                                 &lt;span style="color: #008000"&gt;//&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 47:                                 &lt;span style="color: #008000"&gt;// No, i'm not proud of this but meh.. great code happens when you ship v3 :D&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 48:                                 &lt;span style="color: #008000"&gt;//&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 49:                                 &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; dtStr = p2.GetValue(entity, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;).ToString();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 50:                                 DateTime dt = Convert.ToDateTime(dtStr);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 51:                                 System.Diagnostics.Trace.WriteLine(dt.Year);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 52:                                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dt.Year &amp;gt; 1)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 53:                                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 54:                                     p1.SetValue(original, p2.GetValue(entity, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 55:                                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 56:                             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 57:                         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 58:                         &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 59:                         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 60:                             System.Diagnostics.Trace.WriteLine(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 61:                         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 62:                     }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 63:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 64:                 db.SubmitChanges();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 65:                 db.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 66:                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; original;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 67:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 68:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 69: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 70:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 71:         &lt;span style="color: #808080"&gt;/// Create an Entity Row into the LINQ Context&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 72:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 73:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Create&amp;lt;T&amp;gt;(T entity, DataContext db) where T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 74:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 75:             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (db)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 76:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 77:                 Table&amp;lt;T&amp;gt; table = db.GetTable&amp;lt;T&amp;gt;();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 78:                 table.InsertOnSubmit(entity);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 79:                 db.SubmitChanges();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 80:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 81:             db.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 82:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; entity;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 83:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 84: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 85:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 86:         &lt;span style="color: #808080"&gt;/// Read an Entity Row from the LINQ context back (based of Primary Key setting)&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 87:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 88:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Read&amp;lt;T&amp;gt;(T entity, DataContext db) where T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 89:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 90:             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (db)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 91:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 92:                 Table&amp;lt;T&amp;gt; table = db.GetTable&amp;lt;T&amp;gt;();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 93:                 T original = table.FirstOrDefault(e =&amp;gt; e == entity);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 94:                 db.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 95:                 &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; original;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 96:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 97:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 98: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 99:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;100:         &lt;span style="color: #808080"&gt;/// Hard Delete a Row from the LINQ Context. Note, this will DELETE from the database, its recommended you Retire records not Delete them.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;101:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;102:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; HardDelete&amp;lt;T&amp;gt;(T entity, DataContext db) where T : &lt;span style="color: #0000ff"&gt;class&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;103:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;104:             &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; (db)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;105:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;106:                 Table&amp;lt;T&amp;gt; table = db.GetTable&amp;lt;T&amp;gt;();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;107:                 T original = table.FirstOrDefault(e =&amp;gt; e == entity);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;108:                 &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (original != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;109:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;110:                     table.DeleteOnSubmit(original);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;111:                     db.SubmitChanges();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;112:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;113:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;114:             db.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;115:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;116:     }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;117: }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;118: &lt;/pre&gt;&lt;/pre&gt;

&lt;h2&gt;The UserDAO.&lt;/h2&gt;

&lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 433px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 250px; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  1: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  2: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.Linq;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  3: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Linq;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  4: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; JARVIS.Models.Security.TO;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  5: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Reflection;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  6: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.Linq.Mapping;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  7: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; JARVIS.Lib.DAL;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  8: &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; JARVIS.Models.Security.DAO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  9: {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 10:     &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 11:     &lt;span style="color: #808080"&gt;/// JARVIS.User Data Access Object&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 12:     &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 13:     &lt;span style="color: #808080"&gt;/// &amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 14:     &lt;span style="color: #808080"&gt;/// TODO: &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 15:     &lt;span style="color: #808080"&gt;/// - Add Triggers for Realtional Data (ie Users Roles etc) for Delete  Method&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 16:     &lt;span style="color: #808080"&gt;/// &amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 17:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; UserDAO : BaseDAO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 18:     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 19:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 20:         &lt;span style="color: #808080"&gt;/// Update a UserTO from the Persistance Layer based off the UserId&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 21:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 22:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Update&amp;lt;T&amp;gt;(T entityTO) where T : UserTO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 23:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 24: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 25:             var db = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 26:             JARVIS_User entity = entityTO.ConvertToLINQ(entityTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 27:             entity.ModifiedDate = DateTime.Now;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 28:             JARVIS_User updated = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Update(entity, db) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; JARVIS_User;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 29:             T result = entityTO.ConvertToTO(updated) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; T;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 30:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 31:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 32: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 33:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 34:         &lt;span style="color: #808080"&gt;/// Retire a UserTO from the Persistance Layer based off the UserId&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 35:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 36:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Delete&amp;lt;T&amp;gt;(T entityTO) where T : UserTO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 37:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 38:             var db = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 39:             JARVIS_User entity = entityTO.ConvertToLINQ(entityTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 40: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 41:             &lt;span style="color: #008000"&gt;// TimeStamp the UserTO Modification Dates and Mark for Retirement.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 42:             entity.ModifiedDate = DateTime.Now;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 43:             entity.IsRetired = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 44: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 45:             &lt;span style="color: #008000"&gt;// Return a Modified UserTO&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 46:             JARVIS_User updated = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Update(entity, db) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; JARVIS_User;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 47:             T result = entityTO.ConvertToTO(updated) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; T;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 48:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 49:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 50: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 51:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 52:         &lt;span style="color: #808080"&gt;/// Create a UserTO into the Persistance Layer&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 53:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 54:         &lt;span style="color: #808080"&gt;/// &amp;lt;returns&amp;gt;An updated UserTO&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 55:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Create&amp;lt;T&amp;gt;(T entityTO) where T : UserTO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 56:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 57: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 58:             var db = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 59:             JARVIS_User entity = entityTO.ConvertToLINQ(entityTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 60: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 61:             &lt;span style="color: #008000"&gt;// Modify the Timestamps.&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 62:             entity.CreatedDate = DateTime.Now;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 63:             entity.ModifiedDate = DateTime.Now;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 64:             &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Create(entity, db);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 65:             T result = entityTO &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; T;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 66:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 67:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 68: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 69:         &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 70:         &lt;span style="color: #808080"&gt;/// Return a UserTO from the Persistance Layer based off the UserId&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 71:         &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 72:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; T Read&amp;lt;T&amp;gt;(T entityTO) where T : UserTO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 73:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 74:             var db = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 75:             JARVIS_User entity = entityTO.ConvertToLINQ(entityTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 76:             JARVIS_User updated = &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;.Read(entity, db);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 77:             T result = entityTO.ConvertToTO(updated) &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; T;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 78:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; result;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 79:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 80:     }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 81: }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 82: &lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, fairly simplified approach from here on out, essentially what I’ll do here is simply map the &lt;strong&gt;T&lt;/strong&gt; to the appropriate Type and ensure I go between my Transfer Object type to the LINQ type and back again, always ensuring the code beyond &lt;strong&gt;UserDAO&lt;/strong&gt; really has no clue as to what flavor of LINQ I'm using.&lt;/p&gt;

&lt;h2&gt;The UserTO.&lt;/h2&gt;

&lt;p&gt;I’m a bit of a fan of &lt;a href="http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html" target="_blank"&gt;Transfer Objects&lt;/a&gt;, but again, I’m lazy and well the correct thing to do here would be to NOT inherit the LINQ table &lt;strong&gt;JARVIS_User&lt;/strong&gt;, but since the fields are already there and I hate typing, its “meh” to any whom object.&lt;/p&gt;

&lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 430px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 253px; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  1: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Data.Linq.Mapping;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  2: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Reflection;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  3: &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; JARVIS.Models.Security.TO
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  4: {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  5:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; UserTO : JARVIS_User
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  6:     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  7: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  8: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  9:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; UserTO ConvertToTO(JARVIS_User userTO)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 10:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 11:             var context = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 12:             var model = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AttributeMappingSource().GetModel(context.GetType());
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 13:             UserTO instance = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UserTO();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 14:             MetaTable tbl = model.GetTable(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(JARVIS_User));
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 15:             &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var dm &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; tbl.RowType.DataMembers)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 16:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 17:                 &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 18:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 19:                     PropertyInfo p1 = instance.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 20:                     PropertyInfo p2 = userTO.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 21:                     p1.SetValue(instance, p2.GetValue(userTO, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 22:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 23:                 &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 24:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 25:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 26:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 27:             context.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 28:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; instance;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 29:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 30: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 31: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 32:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; JARVIS_User ConvertToLINQ(UserTO userTO)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 33:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 34:             var context = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVISDBDataContext();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 35:             var model = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AttributeMappingSource().GetModel(context.GetType());
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 36:             JARVIS_User instance = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; JARVIS_User();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 37:             MetaTable tbl = model.GetTable(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(JARVIS_User));
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 38:             &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var dm &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; tbl.RowType.DataMembers)
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 39:             {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 40:                 &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 41:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 42:                     PropertyInfo p1 = instance.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 43:                     PropertyInfo p2 = userTO.GetType().GetProperty(dm.MappedName);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 44:                     p1.SetValue(instance, p2.GetValue(userTO, &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;), &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 45:                     &lt;span style="color: #008000"&gt;//System.Diagnostics.Trace.WriteLine(p1.GetValue(instance,null));&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 46:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 47:                 &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 48:                 {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 49:                 }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 50:             }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 51:             context.Dispose();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 52:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; instance;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 53:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 54:     }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 55: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 56: }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 57: &lt;/pre&gt;&lt;/pre&gt;

&lt;h2&gt;The Test.&lt;/h2&gt;

&lt;p&gt;In this Test, It simply shows the various routines being fired within context to all of the above.&lt;/p&gt;

&lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 436px; padding-top: 5px; border-bottom: #cecece 1px solid; height: 365px; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  1: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  2: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; JARVIS.Models.Security.DAO;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  3: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; JARVIS.Models.Security.TO;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  4: &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  5: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  6: &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; JARVIS.Tests.Controllers
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  7: {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  8:     &lt;span style="color: #808080"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  9:     &lt;span style="color: #808080"&gt;/// Summary description for SecurityController&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 10:     &lt;span style="color: #808080"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 11:     [TestClass]
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 12:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SecurityController
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 13:     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 14:         [TestMethod]
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 15:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; UserAccountTest()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 16:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 17: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 18:             &lt;span style="color: #008000"&gt;// DAO&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 19:             UserDAO dao = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UserDAO();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 20: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 21:             &lt;span style="color: #008000"&gt;// User Entity.            &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 22:             UserTO userTO = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UserTO();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 23:             &lt;span style="color: #008000"&gt;//userTO.UserId = new Guid(&amp;quot;e47dcd57-4c91-4118-b9c5-027de0270620&amp;quot;);&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 24:             userTO.UserId = Guid.NewGuid();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 25:             userTO.Username = &amp;quot;&lt;span style="color: #8b0000"&gt;scbarnes&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 26:             userTO.Password = &amp;quot;&lt;span style="color: #8b0000"&gt;itsasecret&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 27:             userTO.DisplayName = &amp;quot;&lt;span style="color: #8b0000"&gt;None&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 28:             userTO.Email = &amp;quot;&lt;span style="color: #8b0000"&gt;&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 29:             userTO.IsActive = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 30:             userTO.CreatedBy = userTO.UserId;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 31:             userTO.ModifiedBy = userTO.UserId;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 32: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 33:             &lt;span style="color: #008000"&gt;// CREATE&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 34:             UserTO o1 = dao.Create(userTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 35: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 36:             &lt;span style="color: #008000"&gt;// UPDATE            &lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 37:             userTO.Username = &amp;quot;&lt;span style="color: #8b0000"&gt;UsernameUpdated&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 38:             UserTO o2 = dao.Update(userTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 39: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 40:             &lt;span style="color: #008000"&gt;// DELETE&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 41:             dao.Delete(userTO);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 42: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 43:             &lt;span style="color: #008000"&gt;// READ&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 44:             UserTO o3 = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UserTO();
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 45:             o3.UserId = o2.UserId;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 46:             UserTO o4 = dao.Read(o3);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 47: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 48:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 49: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 50:     }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt; 51: }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 52: &lt;/pre&gt;&lt;/pre&gt;

&lt;h2&gt;The Versions Used..&lt;/h2&gt;

&lt;p&gt;I’m currently using the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A24D1E00-CD35-4F66-BAA0-2362BDDE0766&amp;amp;displaylang=en" target="_blank"&gt;ASP.NET MVC Beta&lt;/a&gt; which was released on 10/15/2008.&amp;#160; (.NET 3.5).&lt;/p&gt;

&lt;h2&gt;The End.&lt;/h2&gt;

&lt;p&gt;Look, I’m not saying its “champagne C#” and I’m sure it will ruffle a few feathers of some dire hard pattern fans, but at the end of the day, I’ve put in enough layers of abstraction here to allow for trouble to be stomped out. In the event the above becomes to taxing on the server loads, it’s easily swapped in / out from the DAO level down, and that in itself is the true power of object orientated programming.&lt;/p&gt;

&lt;p&gt;Will it win me the Martin Fowler award of excellence, probably not, but hey, I’m shipping :)&lt;/p&gt;

&lt;p&gt;Scott Out.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9305533" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/MVC/default.aspx">MVC</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/Design+Patterns/default.aspx">Design Patterns</category></item><item><title>Silence is &lt;bleep&gt; Golden.</title><link>http://blogs.msdn.com/msmossyblog/archive/2008/10/09/silence-is-bleep-golden.aspx</link><pubDate>Thu, 09 Oct 2008 08:18:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8992458</guid><dc:creator>scbarnes</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/msmossyblog/comments/8992458.aspx</comments><wfw:commentRss>http://blogs.msdn.com/msmossyblog/commentrss.aspx?PostID=8992458</wfw:commentRss><wfw:comment>http://blogs.msdn.com/msmossyblog/rsscomments.aspx?PostID=8992458</wfw:comment><description>&lt;p&gt;&lt;img height="269" alt="ari" src="http://blogs.msdn.com/blogfiles/msmossyblog/WindowsLiveWriter/SilenceisbleepGolden_1397E/ari_3.jpg" width="430" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;If you've watched Entourage you may chuckle. The point of this post is simply that I'm silent for a reason, I'm busy, really busy (PDC is coming so behind the scenes work needs to be done).&lt;/p&gt;  &lt;p&gt;That being said, I had lunch with &lt;a href="http://code.msdn.microsoft.com/mef"&gt;Glenn Block&lt;/a&gt; today and he's shown me an awesome work-around to a common problem amongst many Silverlight coders out there. I'm busting to tell you it, but I'll respect his wishes and simply leave you begging for more.&lt;/p&gt;  &lt;p&gt;Glenn and I have been talking about various ways one can approach Silverlight development and I plan on tricking him into helping me with the Project Nexus.&lt;/p&gt;  &lt;p&gt;On a side note, the lawyers came back and MS Project Nexus is not a good thing for me to use, given it may infringe on MS Project's trademark (which is fair enough). Also apparently Microsoft has already had a project named Nexus, so instead I've renamed the project to JARVIS (&lt;strong&gt;J&lt;/strong&gt;ust &lt;strong&gt;A&lt;/strong&gt; &lt;strong&gt;R&lt;/strong&gt;ather &lt;strong&gt;V&lt;/strong&gt;ery &lt;strong&gt;I&lt;/strong&gt;ntelligent &lt;strong&gt;S&lt;/strong&gt;ystem).&lt;/p&gt;  &lt;p&gt;Internally, I've gotten a lot of &amp;quot;how can I help&amp;quot; with this idea, and so once I can clear my workload for the onramp to PDC, I'll be back on top of the kickoff.&lt;/p&gt;  &lt;p&gt;I've also done some prototypes in the mean time to acid test a few theories and with the help of guys like &lt;a href="http://code.msdn.microsoft.com/mef"&gt;Glenn of MEF fame&lt;/a&gt;, I'm more confident I can get this idea off the ground.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Related Posts:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/msmossyblog/archive/2008/09/19/introducing-ms-project-nexus.aspx"&gt;Introducing - MS Project Nexus&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Silverlight- How to write your own EventDispatcher" href="http://blogs.msdn.com/msmossyblog/archive/2008/06/24/silverlight-how-to-write-your-own-eventdispatcher.aspx"&gt;Silverlight- How to write your own EventDispatcher&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Silverlight- How to Bind Controls to your own Custom Model" href="http://blogs.msdn.com/msmossyblog/archive/2008/06/21/silverlight-how-to-bind-controls-to-your-own-custom-model.aspx"&gt;Silverlight- How to Bind Controls to your own Custom Model&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8992458" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/Nexus/default.aspx">Nexus</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/MVC/default.aspx">MVC</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/JARVISL/default.aspx">JARVISL</category></item><item><title>Playing with ASP.NET MVC.</title><link>http://blogs.msdn.com/msmossyblog/archive/2008/09/17/playing-with-asp-net-mvc.aspx</link><pubDate>Wed, 17 Sep 2008 08:38:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8954910</guid><dc:creator>scbarnes</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/msmossyblog/comments/8954910.aspx</comments><wfw:commentRss>http://blogs.msdn.com/msmossyblog/commentrss.aspx?PostID=8954910</wfw:commentRss><wfw:comment>http://blogs.msdn.com/msmossyblog/rsscomments.aspx?PostID=8954910</wfw:comment><description>&lt;p&gt;I must say, ASP.NET has always been a love/hate relationship with me and it has nothing to do with the technology, more my mind trying to melt to the way ASP.NET works vs JSP/Coldfusion.&lt;/p&gt;  &lt;p&gt;Hey, I spent 10 years doing the later, &lt;a href="http://en.wikipedia.org/wiki/Grok"&gt;groking&lt;/a&gt; ASP.NET in terms of concepts has always tripped me up.&lt;/p&gt;  &lt;p&gt;ASP.NET MVC however for me is very similar to &lt;a href="http://www.mach-ii.com/"&gt;Mach-II&lt;/a&gt; in Coldfusion. So much so, I wanted to look for a way to have a Controller sit in one spot, but bring in Views from another (ie not automated, but wanted to configure it myself).&lt;/p&gt;  &lt;p&gt;I searched online as best I could and couldn't find it, and part of the blame for this is simply &amp;quot;how do I phrase the question&amp;quot;.&lt;/p&gt;  &lt;p&gt;I then went back to what i've jokingly called &amp;quot;MVC Bible&amp;quot;&amp;#160; &lt;a href="http://weblogs.asp.net/stephenwalther/archive/2008/07/23/asp-net-mvc-tip-24-retrieve-views-from-different-folders.aspx"&gt;Stephen Walther's blog.&lt;/a&gt; I clicked on his Tips (as I was frustrated and decided to take my mind off the problem and see what's good in MVC via Stephen) and then &lt;a href="http://weblogs.asp.net/stephenwalther/archive/2008/07/23/asp-net-mvc-tip-24-retrieve-views-from-different-folders.aspx"&gt;I noticed this post on how to do it..&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The magic answer is:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre style="border-right: #cecece 1px solid; padding-right: 5px; border-top: #cecece 1px solid; padding-left: 5px; min-height: 40px; padding-bottom: 5px; overflow: auto; border-left: #cecece 1px solid; width: 430px; padding-top: 5px; border-bottom: #cecece 1px solid; background-color: #fbfbfb"&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  1:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; UserProfileController : Controller
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  2:     {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  3:         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ActionResult Index()
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  4:         {
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  5:             ViewData[&amp;quot;&lt;span style="color: #8b0000"&gt;Title&lt;/span&gt;&amp;quot;] = &amp;quot;&lt;span style="color: #8b0000"&gt;User Profiles&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  6:             ViewData[&amp;quot;&lt;span style="color: #8b0000"&gt;Message&lt;/span&gt;&amp;quot;] = &amp;quot;&lt;span style="color: #8b0000"&gt;Welcome to ASP.NET MVC!&lt;/span&gt;&amp;quot;;
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffff00"&gt;  7:             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; View(@&amp;quot;&lt;span style="color: #8b0000"&gt;~\Views\Admin\Security\UserProfiles\ViewAllUsers.aspx&lt;/span&gt;&amp;quot;);
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt;  8: 
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #fbfbfb"&gt;  9:         }
&lt;/pre&gt;&lt;pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; background-color: #ffffff"&gt; 10:     }&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;It's that simple.&lt;/p&gt;

&lt;p&gt;Ok, with that, I went off and continued coding and it all now is singing together nicely. The point of this thread is that I love how Stephen's structured this approach, basically &amp;quot;Tips for MVC&amp;quot;.&lt;/p&gt;

&lt;p&gt;I'd love to see someone do this for WPF &amp;amp; Silverlight in such a structured fashion.&lt;/p&gt;

&lt;p&gt;Anyone?&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8954910" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/ASP.NET+MVC/default.aspx">ASP.NET MVC</category><category domain="http://blogs.msdn.com/msmossyblog/archive/tags/MVC/default.aspx">MVC</category></item></channel></rss>