<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><id>tag:blogger.com,1999:blog-1793895915475788035</id><updated>2009-10-13T19:44:03.826Z</updated><title type="text">Adverse conditionals</title><subtitle type="html">.NET coding n that</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/AdverseConditionals" type="application/atom+xml" /><feedburner:browserFriendly></feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-150964836514343366</id><published>2009-02-24T20:08:00.001Z</published><updated>2009-03-19T23:43:03.217Z</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title type="text">Static links for aspx pages in 20 lines of code</title><content type="html">Still using WebForms? Sick of magic string URLs that break when you move you ASPX pages around? Try this! I've created a class called UrlFor&amp;lt;TSomePage&amp;gt;. It examines the page class and figures out the URL by making a few assumptions about your aspx pages (the aspx file has the same name as the class, the namespaces match the folder structure, that kind of thing...)   &lt;pre class="brush: csharp"&gt;public class UrlFor&amp;lt;TAspxPage&amp;gt;
    where TAspxPage : Page
    private static string baseUrl = typeof(TAspxPage).FullName.Substring(&amp;quot;YourAppBaseNamespace&amp;quot;.Length).Replace('.', '/') + &amp;quot;.aspx&amp;quot;;

    public Dictionary&amp;lt;string, string&amp;gt; QueryString = new Dictionary&amp;lt;string, string&amp;gt;();

    public UrlFor&amp;lt;TAspxPage&amp;gt; Set&amp;lt;TValue&amp;gt;(Expression&amp;lt;Func&amp;lt;TAspxPage, TValue&amp;gt;&amp;gt; getProp, TValue value)
    {
        this.QueryString[((MemberExpression)getProp.Body).Member.Name] = value.ToString();
        return this;
    }
    public override string ToString()
    {
        var qs = String.Join(&amp;quot;&amp;amp;&amp;quot;, this.QueryString.Select(pair =] pair.Key + &amp;quot;=&amp;quot; + HttpUtility.UrlEncode(pair.Value)).ToArray());
        return baseUrl + (qs.Length ] 0 ? (&amp;quot;?&amp;quot; + qs) : String.Empty);
    }
}&lt;/pre&gt;
anyway, it lets you write things like this in your code: 

&lt;pre&gt;[%= new UrlFor&amp;lt;Meetings.Details&amp;gt;().Set(d =&amp;gt; d.WorkspaceId, 1).Set(d =&amp;gt; d.MeetingId, 2) %&amp;gt;&lt;/pre&gt;
where Meeting.Details is a Page class with a property on it called MeetingId and one called WorkspaceId. This generates a url like 

&lt;pre&gt;/Meetings/Details.aspx?WorkspaceId=1&amp;amp;MeetingId=2&lt;/pre&gt;
Of course your pages may not have properties that correspond to the querystring parameters, but you can always write an extension like 

&lt;pre class="brush: csharp"&gt;public static class UrlForExt
{
    public static UrlFor&amp;lt;T&amp;gt; SetWorkspaceId&amp;lt;T&amp;gt;(this UrlFor&amp;lt;T&amp;gt; url, int value)
        where T:WorkspacePage
    {
        url.QueryString[&amp;quot;workspaceid&amp;quot;] = value.ToString();
        return url;
    }
}&lt;/pre&gt;
and get the same effect by writing something like 

&lt;pre class="brush: csharp"&gt;new UrlFor&amp;lt;Default&amp;gt;().SetWorkspaceId(1)&lt;/pre&gt;
Neat huh!? Use this to build your links and you can rename and move your pages to your hearts content!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-150964836514343366?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/150964836514343366/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2009/02/static-links-for-aspx-pages-in-20-lines.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/150964836514343366" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/150964836514343366" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2009/02/static-links-for-aspx-pages-in-20-lines.html" title="Static links for aspx pages in 20 lines of code" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-1158447947232993072</id><published>2009-02-09T01:09:00.001Z</published><updated>2009-02-09T01:09:15.279Z</updated><title type="text">MigrationScriptGenerator</title><content type="html">&lt;p&gt;Hi all, I thought I'd give you all a heads up on a new tool I've written for keeping your database schema in sync with your development schema   &lt;br /&gt;Basically its a tool for generating SQL scripts for changes (using Open DBDiff), with errors if you do a change that might lose data. It creates a script to you to review. If your changes are non destructive, then it just makes the change script for you.    &lt;br /&gt;Its pretty alpha at the moment, but seems functional enough for development work. Check out the sample project - it's hooked up with Fluent NHibernate. Try changing some of the entity classes and rebuilding, and have a look in the /Sql folder at the generated scripts.    &lt;br /&gt;You can find it at &lt;a href="http://code.google.com/p/migrationscriptgenerator/"&gt;http://code.google.com/p/migrationscriptgenerator/&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-1158447947232993072?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/1158447947232993072/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2009/02/migrationscriptgenerator.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/1158447947232993072" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/1158447947232993072" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2009/02/migrationscriptgenerator.html" title="MigrationScriptGenerator" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-4248831085681223292</id><published>2009-01-18T17:24:00.004Z</published><updated>2009-01-23T09:45:20.191Z</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net" /><category scheme="http://www.blogger.com/atom/ns#" term="NHibernate" /><category scheme="http://www.blogger.com/atom/ns#" term="Fluent NHibernate" /><title type="text">Automatically serializing value objects using Fluent NHibernate</title><content type="html">&lt;p&gt;After reading James Gregory's posts on Fluent NHibernate (in particular &lt;a href="http://blog.jagregory.com/2009/01/11/fluent-nhibernate-auto-mapping-type-conventions/"&gt;http://blog.jagregory.com/2009/01/11/fluent-nhibernate-auto-mapping-type-conventions/&lt;/a&gt;) I had a quick play and came up with this.&lt;/p&gt;  &lt;p&gt;It's very cool how FNH will generate your database for you, but sometimes you want to have a value object instead of an entity, so I have created a generic class you can use which will serialize an object into a field automatically, so add something like this to your FNH conventions.&lt;/p&gt;  

&lt;pre class="csharpcode"&gt;.WithConvention(c =&amp;gt; c.AddTypeConvention(&lt;span class="kwrd"&gt;new&lt;/span&gt; AutoTypeConvention&amp;lt;LatLng&amp;gt;()))&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;So now my class&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Venue
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Id { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Name { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; LatLng Location { get; set; }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Will have the following SQL generated for it by FNH/SchemaExport&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;create&lt;/span&gt; &lt;span class="kwrd"&gt;table&lt;/span&gt; [Venue] (
  Id &lt;span class="kwrd"&gt;INT&lt;/span&gt; &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt; &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
   Location NVARCHAR(&lt;span class="kwrd"&gt;MAX&lt;/span&gt;) &lt;span class="kwrd"&gt;null&lt;/span&gt;,
   Name NVARCHAR(100) &lt;span class="kwrd"&gt;null&lt;/span&gt;,
   &lt;span class="kwrd"&gt;primary&lt;/span&gt; &lt;span class="kwrd"&gt;key&lt;/span&gt; (Id)
)&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
 font-size: small;
 color: black;
 font-family: consolas, "Courier New", courier, monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;The LatLng object will be serialized into the NVARCHAR(MAX) column automatically. Neato! Warning - you should only do this with immutable types (I think) and you might want to use a version tolerant serialization strategy in case the definition of your value type changes from the version serialized in the db. I've provided an XML serializer implementation, feel free to change it!&lt;/p&gt;

&lt;p&gt;You can get the code from &lt;a href="http://www.filefactory.com/file/a027a0b/n/NHibernateAutoPropertyStuff_zip" target="_blank"&gt;here&lt;/a&gt; (apologies for the file hosting)&lt;/p&gt;

UPDATE: The xml serializer is a bit broken - get the latest from http://refactormycode.com/codes/710-polymorphic-xml-serializer#refactor_144121&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-4248831085681223292?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/4248831085681223292/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2009/01/automatically-serializing-value-objects.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4248831085681223292" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4248831085681223292" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2009/01/automatically-serializing-value-objects.html" title="Automatically serializing value objects using Fluent NHibernate" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-8678813890754819168</id><published>2008-10-27T17:37:00.005Z</published><updated>2008-10-27T18:11:46.922Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="sql" /><category scheme="http://www.blogger.com/atom/ns#" term="migrations" /><category scheme="http://www.blogger.com/atom/ns#" term="SimpleScriptRunner" /><title type="text">Announcing SimpleScriptRunner - a very basic migrations tool</title><content type="html">Just thought I'd share a very basic tool called &lt;a href="http://code.google.com/p/simplescriptrunner/"&gt;SimpleScriptRunner&lt;/a&gt;. Its basically just something for running a directory of numbered SQL scripts against a SQL Server database for migrations, using the syntax&lt;div&gt;
&lt;/div&gt;&lt;div class="csharpcode"&gt;SimpleScriptRunner.exe &amp;lt;server&amp;gt; &amp;lt;database&amp;gt; &amp;lt;path to sql scripts&amp;gt;&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;I like to call it from a post build event in a VS project like so:&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div class="csharpcode"&gt;SimpleScriptRunner .\sqlexpress $(SolutionName)Db $(ProjectPath) &lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;If the database doesn't already exist, it will create it. The scripts are run in numerical order (you need to call them something like 0001 - First script.sql), and any scripts that have been already executed against the database are skipped*. &lt;/div&gt;&lt;div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;I had been using &lt;a href="http://code.google.com/p/migratordotnet/"&gt;MigratorDotNet&lt;/a&gt; for my migrations, and its probably a better tool as it can target databases other than SQL Server, but if you're using a lot of MS SQL Server, you might find this handy.&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;You can find it &lt;a href="http://code.google.com/p/simplescriptrunner/"&gt;here &lt;/a&gt;on google code.&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;*actually if you modify the most recent script, it will re-execute it. This is a good thing when you are developing.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-8678813890754819168?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/8678813890754819168/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/10/announcing-simplescriptrunner-very.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/8678813890754819168" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/8678813890754819168" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/10/announcing-simplescriptrunner-very.html" title="Announcing SimpleScriptRunner - a very basic migrations tool" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-7161112581582076868</id><published>2008-07-14T22:41:00.001Z</published><updated>2008-07-14T22:41:43.825Z</updated><title type="text">LinqtoDBMLRunner improvements</title><content type="html">&lt;p&gt;I've made a couple of improvements. Generally you want to make a couple of changes to an element in the xml file once you've selected it. The Apply extension method allows you to chain changes together so you don't need to keep reselecting objects e.g.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;root.Table(&lt;span class="str"&gt;&amp;quot;People&amp;quot;&lt;/span&gt;)
    .Apply(table =&amp;gt; table.Member = &lt;span class="str"&gt;&amp;quot;Persons&amp;quot;&lt;/span&gt;)
    .Apply(table =&amp;gt; table.Type
                        .Apply(type =&amp;gt; type.Name = &lt;span class="str"&gt;&amp;quot;Person&amp;quot;&lt;/span&gt;)
    );&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;The next improvement is a method to automatically recognise single table inheritance from the database, if, of course, you stick to the convention.&lt;/p&gt;

&lt;p&gt;Image you have a table defined with the following SQL. The underscores in the column names are used to indicate that the column should belong to a subclass.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[Device](
    [Id] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [DeviceType] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Mouse_NumberOfButtons] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Keyboard_NumberOfKeys] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Keyboard_WirelessKeyboard_Frequency] [&lt;span class="kwrd"&gt;decimal&lt;/span&gt;](19, 5) &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
)&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;You can then add the line below to your DbmlRunner script&lt;/p&gt;

&lt;pre class="csharpcode"&gt;root.ExtrapolateSubclasses();&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This will rearrange your Dbml mappings to give the correct inheritance, as in the diagram below&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/mcintyre321/SHvWJZ5wGwI/AAAAAAAAACg/XokytEfVm8w/DbmlMappings%5B10%5D.png?imgmax=800"&gt;&lt;img height="458" alt="DbmlMappings" src="http://lh4.ggpht.com/mcintyre321/SHvWJ_C5PqI/AAAAAAAAACk/xrwNiU9Yjp0/DbmlMappings_thumb%5B7%5D.png?imgmax=800" width="457" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This lets you very quickly and easily add new subclasses without having to do any real dbml scripting. A word of warning. It generates the inheritance modifier value for the subclass based on the order the columns appear in the system. If you remove a subclass and its columns once you have data in the system, you'll probably want to manually script the inheritance modifier values yourself. I might make it run off a named enum in the future, theres an idea...&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-7161112581582076868?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/7161112581582076868/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/07/linqtodbmlrunner-improvements.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/7161112581582076868" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/7161112581582076868" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/07/linqtodbmlrunner-improvements.html" title="LinqtoDBMLRunner improvements" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-5084541777297772272</id><published>2008-06-03T17:05:00.003Z</published><updated>2008-06-03T17:37:52.093Z</updated><title type="text">Try-catching in a single line of code</title><content type="html">&lt;p&gt;Do you like reducing your line count at the expense of readability to others? Then you'll like this!&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:b770a6df-b4ac-4271-a2a7-69be4d0f65f2" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;class&lt;/span&gt;&lt;span style="color: #000000;"&gt; FuncExtensions
{
    &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;public&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;static&lt;/span&gt;&lt;span style="color: #000000;"&gt; TResult Catch&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TExc, TResult&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;this&lt;/span&gt;&lt;span style="color: #000000;"&gt; Func&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TResult&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; func, Func&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;TExc, TResult&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; handleException) &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;where&lt;/span&gt;&lt;span style="color: #000000;"&gt; TExc : Exception
    {
        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;
        {
            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; func();
        }
        &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt; (TExc ex)
        {
            &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; handleException(ex);
        }
    }
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;This lets you write things like:&lt;br&gt;
&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:d64c2a7b-666f-45bc-93ea-cd5d261a4948" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; x &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Func&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(DoSomething).Catch((NullReferenceException e) &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;instead of&lt;br&gt;
&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:72219f11-9853-4e58-a8c2-f5f057012568" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; y;
&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;try&lt;/span&gt;&lt;span style="color: #000000;"&gt;
{
    y &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; DoSomething();
}
&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;catch&lt;/span&gt;&lt;span style="color: #000000;"&gt; (NullReferenceException ex)
{
    y &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;;
}&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;You can of course write overloads for Funcs that take more than one parameter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit: &lt;/strong&gt;I've written a version that lets you chain catches but I'm not sure if its better or not...&lt;br&gt;
&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:584e522f-0923-4ba6-a43c-a4f9ca3be584" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;pre style="background-color:White;;overflow: auto;"&gt;&lt;div&gt;&lt;!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt; x &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #0000FF;"&gt;new&lt;/span&gt;&lt;span style="color: #000000;"&gt; Func&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000FF;"&gt;int&lt;/span&gt;&lt;span style="color: #000000;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt;(DoSomething)
    .Catch((NullReferenceException e) &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #800080;"&gt;1&lt;/span&gt;&lt;span style="color: #000000;"&gt;)
    .Catch((NotImplementedException ex) &lt;/span&gt;&lt;span style="color: #000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;-&lt;/span&gt;&lt;span style="color: #800080;"&gt;2&lt;/span&gt;&lt;span style="color: #000000;"&gt;)();&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-5084541777297772272?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/5084541777297772272/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/06/try-catching-in-single-line-of-code.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/5084541777297772272" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/5084541777297772272" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/06/try-catching-in-single-line-of-code.html" title="Try-catching in a single line of code" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-7146557192068925610</id><published>2008-06-02T08:17:00.005Z</published><updated>2008-06-02T08:28:26.388Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Memcached" /><category scheme="http://www.blogger.com/atom/ns#" term="ViewState" /><title type="text">storing ViewState in memcached - the ultimate post</title><content type="html">The HttpModule for storing memcached in the ViewState is dead - I discovered that you can far more easily intercept ViewState using a custom PageAdapter. Please go to &lt;a href="http://code.google.com/p/memcached-viewstate/"&gt;http://code.google.com/p/memcached-viewstate/&lt;/a&gt; for frictionless memcached viewstate goodness! Hopefully this is the end of the matter :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-7146557192068925610?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/7146557192068925610/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/06/storing-viewstate-in-memcached-ultimate.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/7146557192068925610" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/7146557192068925610" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/06/storing-viewstate-in-memcached-ultimate.html" title="storing ViewState in memcached - the ultimate post" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-4096319439201910088</id><published>2008-05-14T13:12:00.001Z</published><updated>2008-05-14T13:12:42.996Z</updated><title type="text">Introducing LinqToDbmlRunner</title><content type="html">&lt;p&gt;I've created a tool based on my &lt;a href="http://www.adverseconditionals.com/2008/05/scripting-changes-to-linq-to-sql-dbml.html"&gt;previous post&lt;/a&gt;. This should allow scripting of dbml changes in a team environment.&lt;/p&gt;  &lt;p&gt;The project is hosted at &lt;a title="http://code.google.com/p/linqtodbmlrunner/" href="http://code.google.com/p/linqtodbmlrunner/"&gt;http://code.google.com/p/linqtodbmlrunner/&lt;/a&gt; Enjoy!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-4096319439201910088?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/4096319439201910088/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/05/introducing-linqtodbmlrunner.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4096319439201910088" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4096319439201910088" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/05/introducing-linqtodbmlrunner.html" title="Introducing LinqToDbmlRunner" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-2847084804201116749</id><published>2008-05-12T15:14:00.004Z</published><updated>2008-05-14T09:12:50.862Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linq To Sql" /><category scheme="http://www.blogger.com/atom/ns#" term="Build process" /><category scheme="http://www.blogger.com/atom/ns#" term="Linq To XSD" /><title type="text">Scripting changes to Linq To SQL DBML files</title><content type="html">&lt;p&gt;I've been playing with Linq To SQL and have been getting very bothered by the method MS expect us to use to develop the mappings. You can't regenerate your dbml schema without overwriting the changes you made in the designer. Not only this, but your changes won't merge well with changes made by other developers on your team when it comes to check-in time as they are all in xml files.&lt;/p&gt;&lt;p&gt;The process that is required for safe, team development that I've come up with is this:&lt;/p&gt;&lt;p&gt;1. Update database schema (using something like &lt;a href="http://code.google.com/p/migratordotnet/"&gt;migratordotnet&lt;/a&gt;)
2. Generate just the dbml file from schema using sqlmetal.exe
3. Run a change script of some kind against the dbml file to update it to include your custom mappings.
4. Generate the classes from the dbml file using sqlmetal.exe&lt;/p&gt;&lt;p&gt;Step 3 is the missing link. You could use xslt, xpath or Linq to XML. You could even generate change scripts using the designer and &lt;a href="http://msdn.microsoft.com/en-us/library/aa302294.aspx"&gt;MS XML Diff&lt;/a&gt;. But the easiest thing to use is a &lt;a href="http://blogs.msdn.com/xmlteam/archive/2008/02/21/linq-to-xsd-alpha-0-2.aspx"&gt;Linq To XSD&lt;/a&gt; program and put it in the post build events for a project that contains the generated XSD file as an embedded resource. Linq To XSD gives you typed control over the dbml file in C#.&lt;/p&gt;&lt;p&gt;This lets you write something like this in your script:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:6e75cb86-f20e-4322-88c3-c291f3cb90df" style="PADDING-RIGHT: 0px; DISPLAY: inline; PADDING-LEFT: 0px; FLOAT: none; PADDING-BOTTOM: 0px; MARGIN: 0px; WIDTH: 773px; PADDING-TOP: 0px"&gt;&lt;pre style="OVERFLOW: auto;color:white;" &gt;&lt;span style="color:#000000;"&gt;var dbml &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; XRoot.Load(&lt;/span&gt;&lt;span style="color:#800000;"&gt;@"&lt;/span&gt;&lt;span style="color:#800000;"&gt;..\..\GdwDb.dbml&lt;/span&gt;&lt;span style="color:#800000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;);
&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt;&lt;span style="color:#000000;"&gt; (var table &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;in&lt;/span&gt;&lt;span style="color:#000000;"&gt; dbml.Database.Table)
{
&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt;&lt;span style="color:#000000;"&gt; (var column &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;in&lt;/span&gt;&lt;span style="color:#000000;"&gt; table.Type.Column.Where(c &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt; Char.IsLower(c.Name[&lt;/span&gt;&lt;span style="color:#800080;"&gt;0&lt;/span&gt;&lt;span style="color:#000000;"&gt;])&lt;/span&gt;&lt;span style="color:#000000;"&gt;)
{
column.Name &lt;/span&gt;&lt;span style="color:#000000;"&gt;=&lt;/span&gt;&lt;span style="color:#000000;"&gt; column.Name.ToUpper()[&lt;/span&gt;&lt;span style="color:#800080;"&gt;0&lt;/span&gt;&lt;span style="color:#000000;"&gt;] &lt;/span&gt;&lt;span style="color:#000000;"&gt;+&lt;/span&gt;&lt;span style="color:#000000;"&gt; column.Name.Substring(&lt;/span&gt;&lt;span style="color:#800080;"&gt;1&lt;/span&gt;&lt;span style="color:#000000;"&gt;);
}
}
dbml.Save(&lt;/span&gt;&lt;span style="color:#800000;"&gt;@"&lt;/span&gt;&lt;span style="color:#800000;"&gt;..\..\GdwDb.dbml&lt;/span&gt;&lt;span style="color:#800000;"&gt;"&lt;/span&gt;&lt;span style="color:#000000;"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;
&lt;p&gt;This snippet will update all camelCase field names to PascalCase ones. Of course you can do anything, like creating inheritance mappings, removing prefixes etc. One you write a couple of helper methods you should be away.&lt;/p&gt;&lt;p&gt;I would have thought a similar process could be used for NHibernate and Entity Framework, although I know some people prefer to work backwards from code to database.&lt;/p&gt;&lt;p&gt;You can download the latest version of Linq To XSD from &lt;a href="http://blogs.msdn.com/xmlteam/archive/2008/02/21/linq-to-xsd-alpha-0-2.aspx"&gt;here&lt;/a&gt; and download the Linq classes I generated for the Dbml xsd &lt;a href="http://mcintyre321.googlepages.com/DbmlClasses.cs"&gt;here&lt;/a&gt;. Include that in a project with a reference to Microsoft.Xml.Schema.Linq.DLL and you can create your own mapping update script.&lt;/p&gt;&lt;p&gt;Info on using SqlMetal to generate the dbml file, and the appropriate classes can be found on Ben Hall's blog &lt;a href="http://blog.benhall.me.uk/2007/08/power-of-sqlmetal.html"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;I'll upload a demo project later, as this could all be a little confusing.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-2847084804201116749?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/2847084804201116749/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/05/scripting-changes-to-linq-to-sql-dbml.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/2847084804201116749" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/2847084804201116749" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/05/scripting-changes-to-linq-to-sql-dbml.html" title="Scripting changes to Linq To SQL DBML files" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-2442633594814279492</id><published>2008-05-06T14:16:00.004Z</published><updated>2008-05-06T14:20:19.841Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="Memcached" /><category scheme="http://www.blogger.com/atom/ns#" term="ViewState" /><title type="text">Storing ViewState in memcached part 2</title><content type="html">If you have access to the source code of the web app, you can also create inherit from Page and add the following two methods. I prefer the HttpModule myself, but this is pretty convenient. You'll still need to set up the memcached settings in web.config

&lt;span style="font-family:courier new;font-size:85%;"&gt;protected override void SavePageStateToPersistenceMedium(object state)
{
var key = Guid.NewGuid().ToString();
BeIT.MemCached.MemcachedClient.GetInstance("ViewStateCache").Add(key, state);
base.SavePageStateToPersistenceMedium(new Pair("Key", key));
}
protected override object LoadPageStateFromPersistenceMedium()
{
var pair = (Pair)base.LoadPageStateFromPersistenceMedium();
return BeIT.MemCached.MemcachedClient.GetInstance("ViewStateCache").Add(key, pair.Second);
}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-2442633594814279492?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/2442633594814279492/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/05/viewstate-in-memcached-part-2.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/2442633594814279492" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/2442633594814279492" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/05/viewstate-in-memcached-part-2.html" title="Storing ViewState in memcached part 2" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-4999100796523423836</id><published>2008-05-04T11:40:00.017Z</published><updated>2008-06-02T08:25:24.075Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="HttpModule" /><category scheme="http://www.blogger.com/atom/ns#" term="Memcached" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="ViewState" /><title type="text">Storing ASP.NET ViewState in memcached</title><content type="html">&lt;span style="font-weight: bold;font-size:130%;" &gt;This has been deprecated! Please see &lt;a href="http://www.adverseconditionals.com/2008/06/storing-viewstate-in-memcached-ultimate.html"&gt;this&lt;/a&gt; post &lt;/span&gt;

After reading various old &lt;a href="http://www.hanselman.com/blog/MovingViewStateToTheBottomOfThePage.aspx"&gt;blog &lt;/a&gt;&lt;a href="http://blog.madskristensen.dk/post/An-HttpModule-that-moves-ViewState-to-the-bottom.aspx"&gt;posts &lt;/a&gt;about moving the ViewState to the end of the page using an HttpModule, I decided to create an HttpModule to store the ViewState in memcached, eliminating the need to send the data back and forth to the client and stopping prying eyes from seeing the ViewState.

Halfway through writing the HttpModule, I discovered that &lt;a href="http://philiprieck.com/blog/Default.aspx"&gt;Philip Rieck&lt;/a&gt; had already &lt;a href="http://philiprieck.com/blog/archive/2004/06/17/viewrestate.aspx"&gt;written &lt;/a&gt;a pluggable ViewState manipulation HttpModule, so I made a memcached plugin for it using the &lt;a href="http://code.google.com/p/beitmemcached/"&gt;BeITMemcached &lt;/a&gt;client.

To get this up and running on your site, download the latest source from http://code.google.com/p/memcachedviewstatehttpmodule/ and follow these steps

1. Copy all the code from the Release folder into your web sites bin directory
2. Merge the xml below into your web.config and edit the memcached server addresses
&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;configSections&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;section name="beitmemcached" type="System.Configuration.NameValueSectionHandler" /&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/configSections&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;appSettings&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;add key="viewRestateStore" value="Assembly"/&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;add key="viewRestateStoreType" value="MemcachedViewStateStore.MemcachedViewStateStore,MemcachedViewStateStore"/&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/appSettings&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;beitmemcached&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;add key="ViewStateCache" value="127.0.0.1" /&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/beitmemcached&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;system.web&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;httpModules&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;add name="viewrestate" type="NFission.Web.ViewRestateModule,NFission.Web.ViewRestate"/&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/httpModules&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/system.web&amp;gt;&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;

&lt;/span&gt;3. That should be it. A couple of words of warning. I haven't used this in production yet, but will hopefully do so sometime in the next week. Also, I haven't distibuted the source for Philip Riecks HttpModule as I don't know the licence for it. I had to make a couple of minor changes to get it to work correctly
&lt;ul&gt;&lt;li&gt;I commented out the GZip stuff as I'm not using it&lt;/li&gt;&lt;li&gt;changed line 72 of VsInFilter from &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Buffer.BlockCopy( this.dataBuffer, (int)position, buffer, offset, count);&lt;/span&gt;&lt;/span&gt; to &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;Buffer.BlockCopy( this.dataBuffer, (int)position, buffer, offset, realCount);&lt;/span&gt;&lt;/span&gt;). &lt;/li&gt;&lt;li&gt;changed line 16 of VsFilter from &lt;span style=";font-family:courier new;font-size:85%;"  &gt;private const string ViewstateKey = "name=\"__VIEWSTATE\ value=\"";"&lt;/span&gt; to &lt;span style=";font-family:courier new;font-size:85%;"  &gt;private const string ViewstateKey = "id=\"__VIEWSTATE\" value=\"";&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I'm trying to get in touch with Philip to clear up the licence.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-4999100796523423836?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/4999100796523423836/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/05/storing-aspnet-viewstate-in-memcached.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4999100796523423836" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/4999100796523423836" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/05/storing-aspnet-viewstate-in-memcached.html" title="Storing ASP.NET ViewState in memcached" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-5737407370497975209</id><published>2008-04-16T10:24:00.002Z</published><updated>2008-12-10T20:04:59.294Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="unit testing" /><category scheme="http://www.blogger.com/atom/ns#" term="TransactionScope" /><category scheme="http://www.blogger.com/atom/ns#" term=".net" /><category scheme="http://www.blogger.com/atom/ns#" term="MSDTC" /><title type="text">How To Enable TransactionScope commands for unit tests</title><content type="html">Something plundered from elsewhere on the internet, no doubt. Also insecure, no doubt.&lt;br /&gt;&lt;br /&gt;Go to Administrative Tools-&gt;Component Services&lt;br /&gt;In the Component Services window, go to Component Services, and right click on "my computer". Select "properties".&lt;br /&gt;Click the MSDTC tab, then click the 'Security configuration...' button.&lt;br /&gt;Set the settings to look like this:&lt;img id="BLOGGER_PHOTO_ID_5189787550075412306" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_JQkeZusdO48/SAXUR7X9X1I/AAAAAAAAAB0/8T6YCvSggWU/s320/DTC+settings.png" border="0" /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-5737407370497975209?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/5737407370497975209/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2008/04/how-to-enable-transactionscope-commands.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/5737407370497975209" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/5737407370497975209" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2008/04/how-to-enable-transactionscope-commands.html" title="How To Enable TransactionScope commands for unit tests" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_JQkeZusdO48/SAXUR7X9X1I/AAAAAAAAAB0/8T6YCvSggWU/s72-c/DTC+settings.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1793895915475788035.post-1913975327132481490</id><published>2007-11-05T10:26:00.000Z</published><updated>2007-11-05T10:51:54.290Z</updated><category scheme="http://www.blogger.com/atom/ns#" term="launchy" /><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><title type="text">Quickly navigating solution explorer in Visual Studio</title><content type="html">&lt;p&gt;First post!11!1!!1&lt;/p&gt;&lt;p&gt;Often in Visual Studio I find scrolling around the solution explorer can be a bit of a hassle - if you are moving between files in different projects it can take some time to find the file you want. In order to cut out this annoyance, I have this handy tip:&lt;/p&gt;&lt;p&gt;Install launchy (&lt;a href="http://www.launchy.net/"&gt;http://www.launchy.net/&lt;/a&gt;), a keystoke application launcher, and get it to index .cs files in your solution directory. Now all you need to do to get to a file in Visual Studio is hit alt+space and type the file name and voila! &lt;/p&gt;&lt;p&gt;Its probably also worth enabling "Options -&gt; Projects and Solutions -&gt; Track active item in solution explorer" otherwise Visual Studio gets left behind.


&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1793895915475788035-1913975327132481490?l=www.adverseconditionals.com'/&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.adverseconditionals.com/feeds/1913975327132481490/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.adverseconditionals.com/2007/11/quickly-navigating-solution-explorer-in.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/1913975327132481490" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1793895915475788035/posts/default/1913975327132481490" /><link rel="alternate" type="text/html" href="http://www.adverseconditionals.com/2007/11/quickly-navigating-solution-explorer-in.html" title="Quickly navigating solution explorer in Visual Studio" /><author><name>Harry McIntyre</name><uri>http://www.blogger.com/profile/16748782353710296964</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="02457348459974384478" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></entry></feed>
