<?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-1002597578696693985</id><updated>2009-10-02T12:20:15.084-07:00</updated><title type="text">Developer Stuff!</title><subtitle type="html">A collection of my uncategorized thoughts as a Software Developer</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://developercontainer.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://developercontainer.blogspot.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default?start-index=26&amp;max-results=25" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>74</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/" /><logo>http://www.feedburner.com/fb/images/pub/fb_pwrd.gif</logo><link rel="self" href="http://feeds.feedburner.com/DeveloperStuff" type="application/atom+xml" /><feedburner:emailServiceId>DeveloperStuff</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-473946948253446206</id><published>2009-09-21T16:41:00.000-07:00</published><updated>2009-09-21T16:49:20.683-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="web development" /><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="AJAX" /><category scheme="http://www.blogger.com/atom/ns#" term="selectors" /><category scheme="http://www.blogger.com/atom/ns#" term="ui" /><category scheme="http://www.blogger.com/atom/ns#" term="JAVASCRIPT" /><category scheme="http://www.blogger.com/atom/ns#" term="FireBug" /><category scheme="http://www.blogger.com/atom/ns#" term="html" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><category scheme="http://www.blogger.com/atom/ns#" term="css" /><title type="text">Learn jQuery with FireBug, jQuerify and SelectorGadget</title><content type="html">Learn how Dave Ward (@encosia) uses FireBug, jQuerify and SelectorGadget to learn jQuery and any other client-side technology. Hosted by Craig Shoemaker (@craigshoemaker) for the Polymorphic Podcast &lt;a href="http://polymorphicpodcast.com/" target="_blank"&gt;http://polymorphicpodcast.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/JB6MIV_lHI0&amp;amp;hl=en&amp;amp;fs=1&amp;amp;"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/JB6MIV_lHI0&amp;amp;hl=en&amp;amp;fs=1&amp;amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-473946948253446206?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/pFyh6V5RVPY" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/473946948253446206" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/473946948253446206" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/pFyh6V5RVPY/learn-jquery-with-firebug-jquerify-and.html" title="Learn jQuery with FireBug, jQuerify and SelectorGadget" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/09/learn-jquery-with-firebug-jquerify-and.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-9151660923734649696</id><published>2009-09-02T20:45:00.001-07:00</published><updated>2009-09-02T20:45:43.111-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Object Relational" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="LINQ" /><category scheme="http://www.blogger.com/atom/ns#" term="Code" /><title type="text">LINQ: Building an IQueryable Provider - Part III</title><content type="html">&lt;p&gt;This post is the third in a series of posts covering how to build a LINQ IQueryable provider. If you have not read the previous posts, please do so before proceeding.  &lt;p&gt;&lt;a href="http://blogs.msdn.com/mattwar/pages/linq-links.aspx"&gt;Complete list of posts in the Building an IQueryable Provider series&lt;/a&gt;  &lt;p&gt;Part III? Wasn’t I done in the last post? Didn’t I have the provider actually working, translating, executing and returning a sequence of objects?  &lt;p&gt;Sure, that’s true, but only just so. The provider I built was really fragile. It only understood one major query operator and a few minor ones like comparison, etc. However, real providers are going to have to deal with many more operators and complicated interactions between them. For example, that provider did not even let you project the data into new shapes. How one goes about doing that is non-obvious.  &lt;p&gt;&lt;b&gt;Translating Local Variable References&lt;/b&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;city = &lt;span style="color: #a31515"&gt;"London"&lt;/span&gt;;&lt;br /&gt;var query = db.Customers.Where(c =&amp;gt; c.City == city);&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;What happens when we try to translate that? Go ahead try it. I’m waiting. &lt;br /&gt;&lt;p&gt;Bam! You get an exception, “The member 'city' is not supported.” What does that mean? I thought the ‘member’ city was one of the columns. Well, it is. What the exception is referring to is the local variable ‘city’. Yet, how is that a ‘member’? &lt;br /&gt;&lt;p&gt;Take a look at the ToString() translation of the expression tree.&lt;pre class="code"&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(query.Expression.ToString());&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Here’s what you get: SELECT * FROM Customers.Where(c =&amp;gt; return (c.City = value(Sample.Program+&amp;lt;&amp;gt;c__DisplayClass0).city)) &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Aha! The c# compile has made a class to hold local variables that are being referenced in the lambda expression. This is the same thing it does when local variables are referenced inside an anonymous method. But you already knew that. Didn’t you? No? Regardless, if I want to have my provider work with references to local variables I’m going to have to deal with it. Maybe I can just recognize field references to these compiler generated types? How do I identify a compiler generated type? By name? What if the c# compiler changes how they name them? What if another language uses a different scheme? Are local variables the only interesting case? What about references to member variables in scope at the time? Those aren’t going to be encoded as values in the tree either are they? At best they will be a constant node referencing the instance the member is on and then a MemberAccess node that accesses the member off that instance. Can I just recognize any member access against a constant node and evaluated it by hand using reflection? Maybe. What if the compiler generates something more complicated? Okay, what I’m going to give you is a general purpose solution that will turn these compiler generated trees into something much more palatable, more like the trees you thought you were getting before I pointed out this mess. What I really want to do is identify sub-trees in the overall tree that can be immediately evaluated and turned into values. If I can do this, then the rest of the translator only needs to deal with these values. Thank goodness I already have the ExpressionVisitor defined. I can use that and invent a pretty simple rule to determine what is sub-tree that can be evaluated locally. Take a look at the code first and then I’ll explain how it does what it does.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Evaluator&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// &lt;/span&gt;&lt;span style="color: green"&gt;Performs evaluation &amp;amp; replacement of independent sub-trees&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name="expression"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The root of the expression tree.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;param name="fnCanBeEvaluated"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;A function that decides whether a given expression node can be part of the local function.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;A new tree with sub-trees evaluated and replaced.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;public static &lt;/span&gt;Expression PartialEval(Expression expression, &lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;Expression, &lt;span style="color: blue"&gt;bool&lt;/span&gt;&amp;gt; fnCanBeEvaluated)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SubtreeEvaluator&lt;/span&gt;(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Nominator&lt;/span&gt;(fnCanBeEvaluated).Nominate(expression)).Eval(expression);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// &lt;/span&gt;&lt;span style="color: green"&gt;Performs evaluation &amp;amp; replacement of independent sub-trees&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;            /// &amp;lt;param name="expression"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;The root of the expression tree.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;            /// &amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;A new tree with sub-trees evaluated and replaced.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;public static &lt;/span&gt;Expression PartialEval(Expression expression)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;PartialEval(expression, &lt;span style="color: #2b91af"&gt;Evaluator&lt;/span&gt;.CanBeEvaluatedLocally);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;private static bool &lt;/span&gt;CanBeEvaluatedLocally(Expression expression)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;expression.NodeType != ExpressionType.Parameter;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// &lt;/span&gt;&lt;span style="color: green"&gt;Evaluates &amp;amp; replaces sub-trees when first candidate is reached (top-down)&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SubtreeEvaluator &lt;/span&gt;: ExpressionVisitor&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;HashSet&lt;/span&gt;&amp;lt;Expression&amp;gt; candidates;&lt;br /&gt;                &lt;span style="color: blue"&gt;internal &lt;/span&gt;SubtreeEvaluator(&lt;span style="color: #2b91af"&gt;HashSet&lt;/span&gt;&amp;lt;Expression&amp;gt; candidates)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.candidates = candidates;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;internal &lt;/span&gt;Expression Eval(Expression exp)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;return this&lt;/span&gt;.Visit(exp);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression Visit(Expression exp)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(exp == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;                    }&lt;br /&gt;                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.candidates.Contains(exp))&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.Evaluate(exp);&lt;br /&gt;                    }&lt;br /&gt;                    &lt;span style="color: blue"&gt;return base&lt;/span&gt;.Visit(exp);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;private &lt;/span&gt;Expression Evaluate(Expression e)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(e.NodeType == ExpressionType.Constant)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span style="color: blue"&gt;return &lt;/span&gt;e;&lt;br /&gt;                    }&lt;br /&gt;                    LambdaExpression lambda = Expression.Lambda(e);&lt;br /&gt;                    &lt;span style="color: #2b91af"&gt;Delegate &lt;/span&gt;fn = lambda.Compile();&lt;br /&gt;                    &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Constant(fn.DynamicInvoke(&lt;span style="color: blue"&gt;null&lt;/span&gt;), e.Type);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;            /// &lt;/span&gt;&lt;span style="color: green"&gt;Performs bottom-up analysis to determine which nodes can possibly&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;be part of an evaluated sub-tree.&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Nominator &lt;/span&gt;: ExpressionVisitor&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;Expression, &lt;span style="color: blue"&gt;bool&lt;/span&gt;&amp;gt; fnCanBeEvaluated;&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;HashSet&lt;/span&gt;&amp;lt;Expression&amp;gt; candidates;&lt;br /&gt;                &lt;span style="color: blue"&gt;bool &lt;/span&gt;cannotBeEvaluated;&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;internal &lt;/span&gt;Nominator(&lt;span style="color: #2b91af"&gt;Func&lt;/span&gt;&amp;lt;Expression, &lt;span style="color: blue"&gt;bool&lt;/span&gt;&amp;gt; fnCanBeEvaluated)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.fnCanBeEvaluated = fnCanBeEvaluated;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;internal &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HashSet&lt;/span&gt;&amp;lt;Expression&amp;gt; Nominate(Expression expression)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.candidates = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HashSet&lt;/span&gt;&amp;lt;Expression&amp;gt;();&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(expression);&lt;br /&gt;                    &lt;span style="color: blue"&gt;return this&lt;/span&gt;.candidates;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression Visit(Expression expression)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(expression != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                    {&lt;br /&gt;                        &lt;span style="color: blue"&gt;bool &lt;/span&gt;saveCannotBeEvaluated = &lt;span style="color: blue"&gt;this&lt;/span&gt;.cannotBeEvaluated;&lt;br /&gt;                        &lt;span style="color: blue"&gt;this&lt;/span&gt;.cannotBeEvaluated = &lt;span style="color: blue"&gt;false&lt;/span&gt;;&lt;br /&gt;                        &lt;span style="color: blue"&gt;base&lt;/span&gt;.Visit(expression);&lt;br /&gt;                        &lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: blue"&gt;this&lt;/span&gt;.cannotBeEvaluated)&lt;br /&gt;                        {&lt;br /&gt;                            &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.fnCanBeEvaluated(expression))&lt;br /&gt;                            {&lt;br /&gt;                                &lt;span style="color: blue"&gt;this&lt;/span&gt;.candidates.Add(expression);&lt;br /&gt;                            }&lt;br /&gt;                            &lt;span style="color: blue"&gt;else&lt;br /&gt;                            &lt;/span&gt;{&lt;br /&gt;                                &lt;span style="color: blue"&gt;this&lt;/span&gt;.cannotBeEvaluated = &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;br /&gt;                            }&lt;br /&gt;                        }&lt;br /&gt;                        &lt;span style="color: blue"&gt;this&lt;/span&gt;.cannotBeEvaluated |= saveCannotBeEvaluated;&lt;br /&gt;                    }&lt;br /&gt;                    &lt;span style="color: blue"&gt;return &lt;/span&gt;expression;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The Evaluator class exposes a static method ‘PartialEval’ that you can call to evaluate these sub-trees in your expression, leaving only constant nodes with actual values in their place.&lt;br /&gt;&lt;p&gt;The majority of this code is the demarking of maximal sub-trees that can be evaluated in isolation. The actual evaluation is trivial since the sub-trees can be ‘compiled’ using LambaExpression.Compile, turned into a delegate and then invoked. You can see this happening in the SubtreeVisitor.Evaluate method.&lt;br /&gt;&lt;p&gt;The process of determining maximal sub-trees happens in two steps. First by a bottom-up walk in the Nominator class that determines which nodes could possibly be evaluated in isolation and then a top-down walk in SubtreeEvaluator that finds highest nodes representing sub-trees that were nominated.&lt;br /&gt;&lt;p&gt;The Nominator is parameterized by a function that you supply that can employ whatever heuristics you want to determine if some given node can be evaluated in isolation. The default heuristic is that any node except ExpresssionType.Parameter can be evaluated in isolation. Beyond that, a general rule states that if a child node cannot be evaluated locally then the parent node cannot either. Therefore, any node upstream of a parameter cannot be evaluated and will remain in the tree. Everything else will be evaluated and replaced as constants.&lt;br /&gt;&lt;p&gt;Now that I have this class I can put it to work by using it whenever I go about translating expression trees. Fortunately, I already have this operation factored out into the ‘Translate’ method on the DbQueryProvider class.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DbQueryProvider &lt;/span&gt;: QueryProvider {&lt;br /&gt;        &lt;span style="color: blue"&gt;private string &lt;/span&gt;Translate(Expression expression) {&lt;br /&gt;        expression = Evaluator.PartialEval(expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;return new &lt;/span&gt;QueryTranslator().Translate(expression);&lt;/pre&gt;&lt;pre class="code"&gt;}&lt;/pre&gt;&lt;pre class="code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/pre&gt;&lt;pre class="code"&gt;Now if we try the following code we get a better result:&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;city = &lt;span style="color: #a31515"&gt;"London"&lt;/span&gt;;&lt;br /&gt;var query = db.Customers.Where(c =&amp;gt; c.City == city);&lt;br /&gt;&lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Query:\n{0}\n"&lt;/span&gt;, query);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Which writes:&lt;br /&gt;&lt;p&gt;Query:&lt;br&gt;SELECT * FROM (SELECT * FROM Customers) AS T WHERE (City = 'London')&lt;br /&gt;&lt;p&gt;Exactly what I wanted. This provider is coming along nicely!&lt;br /&gt;&lt;p&gt;Maybe next time I’ll implement Select. J&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://blogs.msdn.com/mattwar/archive/2007/08/01/linq-building-an-iqueryable-provider-part-iii.aspx" target="_blank"&gt;here&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/1002597578696693985-9151660923734649696?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/H1Xz1t79Zf0" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/9151660923734649696" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/9151660923734649696" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/H1Xz1t79Zf0/linq-building-iqueryable-provider-part_02.html" title="LINQ: Building an IQueryable Provider - Part III" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/09/linq-building-iqueryable-provider-part_02.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-5278680549287073254</id><published>2009-09-01T19:13:00.001-07:00</published><updated>2009-09-02T20:46:34.850-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Object Relational" /><category scheme="http://www.blogger.com/atom/ns#" term="Data" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="LINQ" /><category scheme="http://www.blogger.com/atom/ns#" term="Code" /><title type="text">LINQ: Building an IQueryable Provider - Part II</title><content type="html">&lt;p&gt;This is the second post in a multi-post series on building LINQ providers using the IQueryable interface. If you are new to this series please read the following post before proceeding.  &lt;p&gt;&lt;a href="http://blogs.msdn.com/mattwar/pages/linq-links.aspx"&gt;Complete list of posts in the Building an IQueryable Provider series&lt;/a&gt;  &lt;p&gt;Now, that I’ve laid the groundwork defining a reusable version of IQueryable and IQueryProvider, namely Query&amp;lt;T&amp;gt; and QueryProvider, I’m going to build a provider that actually does something. As I said before, what a query provider really does is execute a little bit of ‘code’ defined as an expression tree instead of actual IL. Of course, it does not actually have to execute it in the traditional sense. For example, LINQ to SQL translates the query expression into SQL and sends it to the server to execute it.  &lt;p&gt;My sample below is going to work much like LINQ to SQL in that it translates and executes a query against an ADO provider. However, I must add a disclaimer here, this sample is not a full-fledge provider in any sense. I’m only going to handle translating the ‘Where’ operation and I’m not even going to attempt to do anything more complicated than allow the predicate to contain a field reference and few simple operators. I may expand on this provider in the future, but for now it is mostly for illustrative purposes only. Please don’t cut and paste and expect to have ship-quality code.  &lt;p&gt;The provider is going to basically do two things; 1) translate the query into a SQL command text and 2) translate the result of executing the command into objects.  &lt;p&gt;&lt;b&gt;The Query Translator&lt;/b&gt;  &lt;p&gt;The query translator is going to simply visit each node in the query’s expression tree and translate the supported operations into text using a StringBuilder. For the sake of clarity assume there is a class called ExpressionVisitor that defines the base visitor pattern for Expression nodes. (I promise I’ll actually include the code for this at the end of the post but for now bear with me.)&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;internal class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;QueryTranslator &lt;/span&gt;: ExpressionVisitor&lt;br /&gt;{&lt;br /&gt;    StringBuilder sb;&lt;br /&gt;    &lt;span style="color: blue"&gt;internal &lt;/span&gt;QueryTranslator()&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;    &lt;span style="color: blue"&gt;internal string &lt;/span&gt;Translate(Expression expression)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.sb = &lt;span style="color: blue"&gt;new &lt;/span&gt;StringBuilder();&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.sb.ToString();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private static &lt;/span&gt;Expression StripQuotes(Expression e)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;while &lt;/span&gt;(e.NodeType == ExpressionType.Quote)&lt;br /&gt;        {&lt;br /&gt;            e = ((UnaryExpression)e).Operand;&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;e;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression VisitMethodCall(MethodCallExpression m)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(m.Method.DeclaringType == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(Queryable) &amp;amp;&amp;amp; m.Method.Name == &lt;span style="color: #a31515"&gt;"Where"&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            sb.Append(&lt;span style="color: #a31515"&gt;"SELECT * FROM ("&lt;/span&gt;);&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(m.Arguments[0]);&lt;br /&gt;            sb.Append(&lt;span style="color: #a31515"&gt;") AS T WHERE "&lt;/span&gt;);&lt;br /&gt;            LambdaExpression lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(lambda.Body);&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;m;&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;throw new &lt;/span&gt;NotSupportedException(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"The method '{0}' is not supported"&lt;/span&gt;, m.Method.Name));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression VisitUnary(UnaryExpression u)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;switch &lt;/span&gt;(u.NodeType)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Not:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" NOT "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(u.Operand);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;default&lt;/span&gt;:&lt;br /&gt;                &lt;span style="color: blue"&gt;throw new &lt;/span&gt;NotSupportedException(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"The unary operator '{0}' is not supported"&lt;/span&gt;, u.NodeType));&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;u;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression VisitBinary(BinaryExpression b)&lt;br /&gt;    {&lt;br /&gt;        sb.Append(&lt;span style="color: #a31515"&gt;"("&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Left);&lt;br /&gt;        &lt;span style="color: blue"&gt;switch &lt;/span&gt;(b.NodeType)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.And:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" AND "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Or:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" OR"&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Equal:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" = "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.NotEqual:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" &amp;lt;&amp;gt; "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.LessThan:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" &amp;lt; "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.LessThanOrEqual:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" &amp;lt;= "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.GreaterThan:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" &amp;gt; "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.GreaterThanOrEqual:&lt;br /&gt;                sb.Append(&lt;span style="color: #a31515"&gt;" &amp;gt;= "&lt;/span&gt;);&lt;br /&gt;                &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue"&gt;default&lt;/span&gt;:&lt;br /&gt;                &lt;span style="color: blue"&gt;throw new &lt;/span&gt;NotSupportedException(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"The binary operator '{0}' is not supported"&lt;/span&gt;, b.NodeType));&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Right);&lt;br /&gt;        sb.Append(&lt;span style="color: #a31515"&gt;")"&lt;/span&gt;);&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;b;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression VisitConstant(ConstantExpression c)&lt;br /&gt;    {&lt;br /&gt;        IQueryable q = c.Value &lt;span style="color: blue"&gt;as &lt;/span&gt;IQueryable;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(q != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: green"&gt;// assume constant nodes w/ IQueryables are table references&lt;br /&gt;            &lt;/span&gt;sb.Append(&lt;span style="color: #a31515"&gt;"SELECT * FROM "&lt;/span&gt;);&lt;br /&gt;            sb.Append(q.ElementType.Name);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else if &lt;/span&gt;(c.Value == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            sb.Append(&lt;span style="color: #a31515"&gt;"NULL"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: blue"&gt;switch &lt;/span&gt;(Type.GetTypeCode(c.Value.GetType()))&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;case &lt;/span&gt;TypeCode.Boolean:&lt;br /&gt;                    sb.Append(((&lt;span style="color: blue"&gt;bool&lt;/span&gt;)c.Value) ? 1 : 0);&lt;br /&gt;                    &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;                &lt;span style="color: blue"&gt;case &lt;/span&gt;TypeCode.String:&lt;br /&gt;                    sb.Append(&lt;span style="color: #a31515"&gt;"'"&lt;/span&gt;);&lt;br /&gt;                    sb.Append(c.Value);&lt;br /&gt;                    sb.Append(&lt;span style="color: #a31515"&gt;"'"&lt;/span&gt;);&lt;br /&gt;                    &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;                &lt;span style="color: blue"&gt;case &lt;/span&gt;TypeCode.Object:&lt;br /&gt;                    &lt;span style="color: blue"&gt;throw new &lt;/span&gt;NotSupportedException(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"The constant for '{0}' is not supported"&lt;/span&gt;, c.Value));&lt;br /&gt;                &lt;span style="color: blue"&gt;default&lt;/span&gt;:&lt;br /&gt;                    sb.Append(c.Value);&lt;br /&gt;                    &lt;span style="color: blue"&gt;break&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;c;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;Expression VisitMemberAccess(MemberExpression m)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(m.Expression != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; m.Expression.NodeType == ExpressionType.Parameter)&lt;br /&gt;        {&lt;br /&gt;            sb.Append(m.Member.Name);&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;m;&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;throw new &lt;/span&gt;NotSupportedException(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"The member '{0}' is not supported"&lt;/span&gt;, m.Member.Name));&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;As you can see, there’s not much there and still it is rather complicated. What I’m expecting to see in the expression tree is at most a method call node with arguments referring to the source (argument 0) and the predicate (argument 1). Take a look at the VisitMethodCall method above. I explicitly handle the case of the Queryable.Where method, generating a “SELECT * FROM (“, recursively visiting the source and then appending “) AS T WHERE “, and then visiting the predicate. This allows for other query operators present in the source expression to be nested sub-queries. I don’t handle any other operators, but if more than one call to Where is used then I’m able to deal with that gracefully. It doesn’t matter what the table alias is that is used (I picked ‘T’) since I’m not going to generate references to it anyway. A more full-fledged provider would of course want to do this. &lt;br /&gt;&lt;p&gt;There’s a little helper method included called StripQutotes. Its job is to strip away any ExpressionType.Quote nodes on the method arguments (which may happen) so I can get at the pure lambda expression that I’m looking for. &lt;br /&gt;&lt;p&gt;The VisitUnary and VisitBinary methods are straightforward. They simply inject the correct text for the specific unary and binary operators I’ve chosen to support. The interesting bit of translation comes in the VisitConstant method. You see, table references in my world are just the root IQueryable’s. If a constant node holds one of my Query&amp;lt;T&amp;gt; instances then I’ll just assume it’s meant to represent the root table so I’ll append “SELECT * FROM” and then the name of the table which is simply the name of the element type of the query. The rest of the translation for constant nodes just deals with actual constants. Note these constants are added to the command text as literal values. There is nothing here to stop injection attacks that real providers need to deal with. &lt;br /&gt;&lt;p&gt;Finally, VisitMemberAccess assumes that all field or property accesses are meant to be column references in the command text. No checking is done to prove that this is true. The name of the field or property is assumed to match the name of the column in the database. &lt;br /&gt;&lt;p&gt;Given a class ‘Customers’ with fields matching the names of the columns in the Northwind sample database, this query translator will generate queries that look like this: &lt;br /&gt;&lt;p&gt;For the query:&lt;pre class="code"&gt;Query&amp;lt;Customers&amp;gt; customers = ...;&lt;br /&gt;    IQueryable&amp;lt;Customers&amp;gt; q = customers.Where(c =&amp;gt; c.City == &lt;span style="color: #a31515"&gt;"London"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt; è&lt;br /&gt;&lt;br /&gt;“SELECT * FROM (SELECT *FROM Customers) AS T WHERE (city = ‘London’)”&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;The Object Reader&lt;/b&gt; &lt;br /&gt;&lt;p&gt;The job of the object reader is to turn the results of a SQL query into objects. I’m going to build a simple class that takes a DbDataReader and a type ‘T’ and I’ll make it implement IEnumerable&amp;lt;T&amp;gt;. There are no bells and whistles in this implementation. It will only work for writing into class fields via reflection. The names of the fields must match the names of the columns in the reader and the types must match whatever the DataReader thinks is the correct type.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;internal class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ObjectReader&lt;/span&gt;&amp;lt;T&amp;gt; : IEnumerable&amp;lt;T&amp;gt;, IEnumerable &lt;span style="color: blue"&gt;where &lt;/span&gt;T : &lt;span style="color: blue"&gt;class&lt;/span&gt;, &lt;span style="color: blue"&gt;new&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: #2b91af"&gt;Enumerator &lt;/span&gt;enumerator;&lt;br /&gt;    &lt;span style="color: blue"&gt;internal &lt;/span&gt;ObjectReader(DbDataReader reader)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.enumerator = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Enumerator&lt;/span&gt;(reader);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;IEnumerator&amp;lt;T&amp;gt; GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: #2b91af"&gt;Enumerator &lt;/span&gt;e = &lt;span style="color: blue"&gt;this&lt;/span&gt;.enumerator;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(e == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;InvalidOperationException(&lt;span style="color: #a31515"&gt;"Cannot enumerate more than once"&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.enumerator = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;e;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    IEnumerator IEnumerable.GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.GetEnumerator();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Enumerator &lt;/span&gt;: IEnumerator&amp;lt;T&amp;gt;, IEnumerator, IDisposable&lt;br /&gt;    {&lt;br /&gt;        DbDataReader reader;&lt;br /&gt;        FieldInfo[] fields;&lt;br /&gt;        &lt;span style="color: blue"&gt;int&lt;/span&gt;[] fieldLookup;&lt;br /&gt;        T current;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;internal &lt;/span&gt;Enumerator(DbDataReader reader)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.reader = reader;&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.fields = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(T).GetFields();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;public &lt;/span&gt;T Current&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return this&lt;/span&gt;.current; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;object &lt;/span&gt;IEnumerator.Current&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return this&lt;/span&gt;.current; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;public bool &lt;/span&gt;MoveNext()&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.Read())&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.fieldLookup == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.InitFieldLookup();&lt;br /&gt;                }&lt;br /&gt;                T instance = &lt;span style="color: blue"&gt;new &lt;/span&gt;T();&lt;br /&gt;                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = &lt;span style="color: blue"&gt;this&lt;/span&gt;.fields.Length; i &amp;lt; n; i++)&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;int &lt;/span&gt;index = &lt;span style="color: blue"&gt;this&lt;/span&gt;.fieldLookup[i];&lt;br /&gt;                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(index &amp;gt;= 0)&lt;br /&gt;                    {&lt;br /&gt;                        FieldInfo fi = &lt;span style="color: blue"&gt;this&lt;/span&gt;.fields[i];&lt;br /&gt;                        &lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.IsDBNull(index))&lt;br /&gt;                        {&lt;br /&gt;                            fi.SetValue(instance, &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;                        }&lt;br /&gt;                        &lt;span style="color: blue"&gt;else&lt;br /&gt;                        &lt;/span&gt;{&lt;br /&gt;                            fi.SetValue(instance, &lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.GetValue(index));&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;this&lt;/span&gt;.current = instance;&lt;br /&gt;                &lt;span style="color: blue"&gt;return true&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;return false&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;public void &lt;/span&gt;Reset()&lt;br /&gt;        {&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;public void &lt;/span&gt;Dispose()&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.Dispose();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;private void &lt;/span&gt;InitFieldLookup()&lt;br /&gt;        {&lt;br /&gt;            Dictionary&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;int&lt;/span&gt;&amp;gt; map = &lt;span style="color: blue"&gt;new &lt;/span&gt;Dictionary&amp;lt;&lt;span style="color: blue"&gt;string&lt;/span&gt;, &lt;span style="color: blue"&gt;int&lt;/span&gt;&amp;gt;(StringComparer.InvariantCultureIgnoreCase);&lt;br /&gt;            &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = &lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.FieldCount; i &amp;lt; n; i++)&lt;br /&gt;            {&lt;br /&gt;                map.Add(&lt;span style="color: blue"&gt;this&lt;/span&gt;.reader.GetName(i), i);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;this&lt;/span&gt;.fieldLookup = &lt;span style="color: blue"&gt;new int&lt;/span&gt;[&lt;span style="color: blue"&gt;this&lt;/span&gt;.fields.Length];&lt;br /&gt;            &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = &lt;span style="color: blue"&gt;this&lt;/span&gt;.fields.Length; i &amp;lt; n; i++)&lt;br /&gt;           {&lt;br /&gt;                &lt;span style="color: blue"&gt;int &lt;/span&gt;index;&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;(map.TryGetValue(&lt;span style="color: blue"&gt;this&lt;/span&gt;.fields[i].Name, &lt;span style="color: blue"&gt;out &lt;/span&gt;index))&lt;br /&gt;                {&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.fieldLookup[i] = index;&lt;br /&gt;                }&lt;br /&gt;                &lt;span style="color: blue"&gt;else&lt;br /&gt;                &lt;/span&gt;{&lt;br /&gt;                    &lt;span style="color: blue"&gt;this&lt;/span&gt;.fieldLookup[i] = -1;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;The ObjectReader creates a new instance of type ‘T’ for each row read by the DbDataReader. It uses the reflection API FieldInfo.SetValue to assign values to each field of the object. When the ObjectReader is first created it instantiates an instance of the nested Enumerator class. This enumerator is handed out when the GetEnumerator method is called. Since DataReader’s cannot reset and execute again, the enumerator can only be handed out once. If GetEnumerator is called a second time an exception is thrown. &lt;br /&gt;&lt;p&gt;The ObjectReader is lenient in the ordering of fields. Since the QueryTranslator builds queries using “SELECT *” this is a must because otherwise the code has no way of knowing which column will appear first in the results. Note that it is generally inadvisable to use “SELECT *” in production code. Remember this is just an illustrative sample to show how in general to put together a LINQ provider. In order to allow for different sequences of columns, the precise sequence is discovered at runtime when the first row is read for the DataReader. The InitFieldLookup function builds a map from column name to column ordinal and then assembles a lookup table ‘fieldLookup’ that maps between the object’s fields and the ordinals. &lt;br /&gt;&lt;p&gt;&lt;b&gt;The Provider&lt;/b&gt; &lt;br /&gt;&lt;p&gt;Now that we have these two pieces (and the classes define in the prior post) it’s quite easy to combine them together to make an actual IQueryable LINQ provider.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DbQueryProvider &lt;/span&gt;: QueryProvider&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    DbConnection connection;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;DbQueryProvider(DbConnection connection)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.connection = connection;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public override string &lt;/span&gt;GetQueryText(Expression expression)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.Translate(expression);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public override object &lt;/span&gt;Execute(Expression expression)&lt;br /&gt;    {&lt;br /&gt;        DbCommand cmd = &lt;span style="color: blue"&gt;this&lt;/span&gt;.connection.CreateCommand();&lt;br /&gt;        cmd.CommandText = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Translate(expression);&lt;br /&gt;        DbDataReader reader = cmd.ExecuteReader();&lt;br /&gt;        Type elementType = TypeSystem.GetElementType(expression.Type);&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;Activator.CreateInstance(&lt;br /&gt;            &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(ObjectReader&amp;lt;&amp;gt;).MakeGenericType(elementType),&lt;br /&gt;            BindingFlags.Instance | BindingFlags.NonPublic, &lt;span style="color: blue"&gt;null&lt;/span&gt;,&lt;br /&gt;            &lt;span style="color: blue"&gt;new object&lt;/span&gt;[] { reader },&lt;br /&gt;            &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private string &lt;/span&gt;Translate(Expression expression)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return new &lt;/span&gt;QueryTranslator().Translate(expression);&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;As you can see, building a provider is now simply an exercise in combining these two pieces. The GetQueryText just needs to use the QueryTranslator to produce the command text. The Execute method uses both QueryTranslator and ObjectReader to build a DbCommand object, execute it and return the results as an IEnumerable. &lt;br /&gt;&lt;p&gt;&lt;b&gt;Trying it Out&lt;/b&gt; &lt;br /&gt;&lt;p&gt;Now that we have our provider we can try it out. Since I’m basically following the LINQ to SQL model I’ll define a class for the Customers table, a ‘Context’ that holds onto the tables (root queries) and a little program that uses them.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Customers&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;CustomerID;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;ContactName;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;Phone;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;City;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;Country;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Orders&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public int &lt;/span&gt;OrderID;&lt;br /&gt;    &lt;span style="color: blue"&gt;public string &lt;/span&gt;CustomerID;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;DateTime OrderDate;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Northwind&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;Query&amp;lt;&lt;span style="color: #2b91af"&gt;Customers&lt;/span&gt;&amp;gt; Customers;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;Query&amp;lt;&lt;span style="color: #2b91af"&gt;Orders&lt;/span&gt;&amp;gt; Orders;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;Northwind(DbConnection connection)&lt;br /&gt;    {&lt;br /&gt;        QueryProvider provider = &lt;span style="color: blue"&gt;new &lt;/span&gt;DbQueryProvider(connection);&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Customers = &lt;span style="color: blue"&gt;new &lt;/span&gt;Query&amp;lt;&lt;span style="color: #2b91af"&gt;Customers&lt;/span&gt;&amp;gt;(provider);&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.Orders = &lt;span style="color: blue"&gt;new &lt;/span&gt;Query&amp;lt;&lt;span style="color: #2b91af"&gt;Orders&lt;/span&gt;&amp;gt;(provider);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Program&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;static void &lt;/span&gt;Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;string &lt;/span&gt;constr = &lt;span style="color: #a31515"&gt;@"…"&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: blue"&gt;using &lt;/span&gt;(SqlConnection con = &lt;span style="color: blue"&gt;new &lt;/span&gt;SqlConnection(constr))&lt;br /&gt;        {&lt;br /&gt;            con.Open();&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Northwind &lt;/span&gt;db = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Northwind&lt;/span&gt;(con);&lt;br /&gt;            IQueryable&amp;lt;&lt;span style="color: #2b91af"&gt;Customers&lt;/span&gt;&amp;gt; query =&lt;br /&gt;                 db.Customers.Where(c =&amp;gt; c.City == &lt;span style="color: #a31515"&gt;"London"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            Console.WriteLine(&lt;span style="color: #a31515"&gt;"Query:\n{0}\n"&lt;/span&gt;, query);&lt;br /&gt;            &lt;span style="color: blue"&gt;var &lt;/span&gt;list = query.ToList();&lt;br /&gt;            &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(&lt;span style="color: blue"&gt;var &lt;/span&gt;item &lt;span style="color: blue"&gt;in &lt;/span&gt;list)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(&lt;span style="color: #a31515"&gt;"Name: {0}"&lt;/span&gt;, item.ContactName);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Now if we run this we should get the following output: (Note that you will have to add your own connection string to the program above.)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Query:&lt;br&gt;SELECT * FROM (SELECT * FROM Customers) AS T WHERE (City = 'London')&lt;br&gt;Name: Thomas Hardy&lt;br&gt;Name: Victoria Ashworth&lt;br&gt;Name: Elizabeth Brown&lt;br&gt;Name: Ann Devon&lt;br&gt;Name: Simon Crowther&lt;br&gt;Name: Hari Kumar &lt;br /&gt;&lt;p&gt;Excellent, just what I wanted. I love it when a plan comes together. J&lt;/p&gt;&lt;br /&gt;&lt;p&gt;That’s it folks. That’s a LINQ IQueryable provider. Well, at least a crude facsimile of one. Of course, yours will do so much more than mine. It will handle all the edge cases and serve coffee. &lt;br /&gt;&lt;p&gt;But wait, there's more.&amp;nbsp; &lt;a href="http://blogs.msdn.com/mattwar/archive/2007/08/01/linq-building-an-iqueryable-provider-part-iii.aspx"&gt;Check out Part III&lt;/a&gt; &lt;br /&gt;&lt;p&gt;&lt;b&gt;APPENDIX – The Expression Visitor&lt;/b&gt; &lt;br /&gt;&lt;p&gt;Now you are in for it. I think I’ve received about an order of magnitude more requests for this class than for help on building a query provider. There is an ExpressionVisitor class in System.Linq.Expressions, however it is internal so it’s not for your direct consumption as much as you’d like it to be. If you shout real loud you might convince us to make that one public in the next go ‘round. &lt;br /&gt;&lt;p&gt;This expression visitor is my take on the (classic) visitor pattern. In this variant there is only one visitor class that dispatches calls to the general Visit function out to specific VisitXXX methods corresponding to different node types. Note not every node type gets it own method, for example all binary operators are treated in one VisitBinary method. The nodes themselves do not directly participate in the visitation process. They are treated as just data. The reason for this is that the quantity of visitors is actually open ended. You can write your own. Therefore no semantics of visiting is coupled into the node classes. It’s all in the visitors. The default visit behavior for node XXX is baked into the base class’s version of VisitXXX. &lt;br /&gt;&lt;p&gt;Another variant is that all VisitXXX methods return a node. The Expression tree nodes are immutable. In order to change the tree you must construct a new one. The default VisitXXX methods will construct a new node if any of its sub-trees change. If no changes are made then the same node is returned. That way if you make a change to a node (by making a new node) deep down in a tree, the rest of the tree is rebuilt automatically for you. &lt;br /&gt;&lt;p&gt;Here’s the code. Enjoy. J&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public abstract class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ExpressionVisitor&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;protected &lt;/span&gt;ExpressionVisitor()&lt;br /&gt;    {&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression Visit(Expression exp)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(exp == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;exp;&lt;br /&gt;        &lt;span style="color: blue"&gt;switch &lt;/span&gt;(exp.NodeType)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Negate:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.NegateChecked:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Not:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Convert:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.ConvertChecked:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.ArrayLength:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Quote:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.TypeAs:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitUnary((UnaryExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Add:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.AddChecked:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Subtract:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.SubtractChecked:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Multiply:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.MultiplyChecked:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Divide:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Modulo:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.And:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.AndAlso:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Or:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.OrElse:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.LessThan:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.LessThanOrEqual:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.GreaterThan:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.GreaterThanOrEqual:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Equal:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.NotEqual:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Coalesce:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.ArrayIndex:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.RightShift:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.LeftShift:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.ExclusiveOr:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitBinary((BinaryExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.TypeIs:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitTypeIs((TypeBinaryExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Conditional:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitConditional((ConditionalExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Constant:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitConstant((ConstantExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Parameter:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitParameter((ParameterExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.MemberAccess:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMemberAccess((MemberExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Call:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMethodCall((MethodCallExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Lambda:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitLambda((LambdaExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.New:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitNew((NewExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.NewArrayInit:&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.NewArrayBounds:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitNewArray((NewArrayExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.Invoke:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitInvocation((InvocationExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.MemberInit:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMemberInit((MemberInitExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;ExpressionType.ListInit:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitListInit((ListInitExpression)exp);&lt;br /&gt;            &lt;span style="color: blue"&gt;default&lt;/span&gt;:&lt;br /&gt;                &lt;span style="color: blue"&gt;throw new &lt;/span&gt;Exception(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"Unhandled expression type: '{0}'"&lt;/span&gt;, exp.NodeType));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;MemberBinding VisitBinding(MemberBinding binding)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;switch &lt;/span&gt;(binding.BindingType)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;MemberBindingType.Assignment:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMemberAssignment((MemberAssignment)binding);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;MemberBindingType.MemberBinding:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMemberMemberBinding((MemberMemberBinding)binding);&lt;br /&gt;            &lt;span style="color: blue"&gt;case &lt;/span&gt;MemberBindingType.ListBinding:&lt;br /&gt;                &lt;span style="color: blue"&gt;return this&lt;/span&gt;.VisitMemberListBinding((MemberListBinding)binding);&lt;br /&gt;            &lt;span style="color: blue"&gt;default&lt;/span&gt;:&lt;br /&gt;                &lt;span style="color: blue"&gt;throw new &lt;/span&gt;Exception(&lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"Unhandled binding type '{0}'"&lt;/span&gt;, binding.BindingType));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;ElementInit VisitElementInitializer(ElementInit initializer)&lt;br /&gt;    {&lt;br /&gt;        ReadOnlyCollection&amp;lt;Expression&amp;gt; arguments = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitExpressionList(initializer.Arguments);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(arguments != initializer.Arguments)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.ElementInit(initializer.AddMethod, arguments);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;initializer;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitUnary(UnaryExpression u)&lt;br /&gt;    {&lt;br /&gt;        Expression operand = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(u.Operand);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(operand != u.Operand)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.MakeUnary(u.NodeType, operand, u.Type, u.Method);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;u;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitBinary(BinaryExpression b)&lt;br /&gt;    {&lt;br /&gt;        Expression left = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Left);&lt;br /&gt;        Expression right = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Right);&lt;br /&gt;        Expression conversion = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Conversion);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(left != b.Left || right != b.Right || conversion != b.Conversion)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(b.NodeType == ExpressionType.Coalesce &amp;amp;&amp;amp; b.Conversion != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Coalesce(left, right, conversion &lt;span style="color: blue"&gt;as &lt;/span&gt;LambdaExpression);&lt;br /&gt;            &lt;span style="color: blue"&gt;else&lt;br /&gt;                return &lt;/span&gt;Expression.MakeBinary(b.NodeType, left, right, b.IsLiftedToNull, b.Method);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;b;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitTypeIs(TypeBinaryExpression b)&lt;br /&gt;    {&lt;br /&gt;        Expression expr = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(b.Expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(expr != b.Expression)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.TypeIs(expr, b.TypeOperand);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;b;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitConstant(ConstantExpression c)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;c;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitConditional(ConditionalExpression c)&lt;br /&gt;    {&lt;br /&gt;        Expression test = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(c.Test);&lt;br /&gt;        Expression ifTrue = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(c.IfTrue);&lt;br /&gt;        Expression ifFalse = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(c.IfFalse);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(test != c.Test || ifTrue != c.IfTrue || ifFalse != c.IfFalse)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Condition(test, ifTrue, ifFalse);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;c;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitParameter(ParameterExpression p)&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;p;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitMemberAccess(MemberExpression m)&lt;br /&gt;    {&lt;br /&gt;        Expression exp = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(m.Expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(exp != m.Expression)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.MakeMemberAccess(exp, m.Member);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;m;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitMethodCall(MethodCallExpression m)&lt;br /&gt;    {&lt;br /&gt;        Expression obj = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(m.Object);&lt;br /&gt;        IEnumerable&amp;lt;Expression&amp;gt; args = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitExpressionList(m.Arguments);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(obj != m.Object || args != m.Arguments)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Call(obj, m.Method, args);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;m;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;ReadOnlyCollection&amp;lt;Expression&amp;gt; VisitExpressionList(ReadOnlyCollection&amp;lt;Expression&amp;gt; original)&lt;br /&gt;    {&lt;br /&gt;        List&amp;lt;Expression&amp;gt; list = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = original.Count; i &amp;lt; n; i++)&lt;br /&gt;        {&lt;br /&gt;            Expression p = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(original[i]);&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                list.Add(p);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;else if &lt;/span&gt;(p != original[i])&lt;br /&gt;            {&lt;br /&gt;                list = &lt;span style="color: blue"&gt;new &lt;/span&gt;List&amp;lt;Expression&amp;gt;(n);&lt;br /&gt;                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;j = 0; j &amp;lt; i; j++)&lt;br /&gt;                {&lt;br /&gt;                    list.Add(original[j]);&lt;br /&gt;                }&lt;br /&gt;                list.Add(p);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;list.AsReadOnly();&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;original;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;MemberAssignment VisitMemberAssignment(MemberAssignment assignment)&lt;br /&gt;    {&lt;br /&gt;        Expression e = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(assignment.Expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(e != assignment.Expression)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Bind(assignment.Member, e);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;assignment;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;MemberMemberBinding VisitMemberMemberBinding(MemberMemberBinding binding)&lt;br /&gt;    {&lt;br /&gt;        IEnumerable&amp;lt;MemberBinding&amp;gt; bindings = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitBindingList(binding.Bindings);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(bindings != binding.Bindings)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.MemberBind(binding.Member, bindings);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;binding;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;MemberListBinding VisitMemberListBinding(MemberListBinding binding)&lt;br /&gt;    {&lt;br /&gt;        IEnumerable&amp;lt;ElementInit&amp;gt; initializers = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitElementInitializerList(binding.Initializers);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(initializers != binding.Initializers)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.ListBind(binding.Member, initializers);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;binding;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;IEnumerable&amp;lt;MemberBinding&amp;gt; VisitBindingList(ReadOnlyCollection&amp;lt;MemberBinding&amp;gt; original)&lt;br /&gt;    {&lt;br /&gt;        List&amp;lt;MemberBinding&amp;gt; list = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = original.Count; i &amp;lt; n; i++)&lt;br /&gt;        {&lt;br /&gt;            MemberBinding b = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitBinding(original[i]);&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                list.Add(b);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;else if &lt;/span&gt;(b != original[i])&lt;br /&gt;            {&lt;br /&gt;                list = &lt;span style="color: blue"&gt;new &lt;/span&gt;List&amp;lt;MemberBinding&amp;gt;(n);&lt;br /&gt;                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;j = 0; j &amp;lt; i; j++)&lt;br /&gt;                {&lt;br /&gt;                    list.Add(original[j]);&lt;br /&gt;                }&lt;br /&gt;                list.Add(b);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;list;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;original;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;IEnumerable&amp;lt;ElementInit&amp;gt; VisitElementInitializerList(ReadOnlyCollection&amp;lt;ElementInit&amp;gt; original)&lt;br /&gt;    {&lt;br /&gt;        List&amp;lt;ElementInit&amp;gt; list = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = 0, n = original.Count; i &amp;lt; n; i++)&lt;br /&gt;        {&lt;br /&gt;            ElementInit init = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitElementInitializer(original[i]);&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                list.Add(init);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;else if &lt;/span&gt;(init != original[i])&lt;br /&gt;            {&lt;br /&gt;                list = &lt;span style="color: blue"&gt;new &lt;/span&gt;List&amp;lt;ElementInit&amp;gt;(n);&lt;br /&gt;                &lt;span style="color: blue"&gt;for &lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;j = 0; j &amp;lt; i; j++)&lt;br /&gt;                {&lt;br /&gt;                    list.Add(original[j]);&lt;br /&gt;                }&lt;br /&gt;                list.Add(init);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(list != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;list;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;original;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitLambda(LambdaExpression lambda)&lt;br /&gt;    {&lt;br /&gt;        Expression body = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(lambda.Body);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(body != lambda.Body)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Lambda(lambda.Type, body, lambda.Parameters);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;lambda;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;NewExpression VisitNew(NewExpression nex)&lt;br /&gt;    {&lt;br /&gt;        IEnumerable&amp;lt;Expression&amp;gt; args = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitExpressionList(nex.Arguments);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(args != nex.Arguments)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(nex.Members != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.New(nex.Constructor, args, nex.Members);&lt;br /&gt;            &lt;span style="color: blue"&gt;else&lt;br /&gt;                return &lt;/span&gt;Expression.New(nex.Constructor, args);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;nex;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitMemberInit(MemberInitExpression init)&lt;br /&gt;    {&lt;br /&gt;        NewExpression n = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitNew(init.NewExpression);&lt;br /&gt;        IEnumerable&amp;lt;MemberBinding&amp;gt; bindings = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitBindingList(init.Bindings);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(n != init.NewExpression || bindings != init.Bindings)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.MemberInit(n, bindings);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;init;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitListInit(ListInitExpression init)&lt;br /&gt;    {&lt;br /&gt;        NewExpression n = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitNew(init.NewExpression);&lt;br /&gt;        IEnumerable&amp;lt;ElementInit&amp;gt; initializers = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitElementInitializerList(init.Initializers);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(n != init.NewExpression || initializers != init.Initializers)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.ListInit(n, initializers);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;init;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitNewArray(NewArrayExpression na)&lt;br /&gt;    {&lt;br /&gt;        IEnumerable&amp;lt;Expression&amp;gt; exprs = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitExpressionList(na.Expressions);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(exprs != na.Expressions)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;if &lt;/span&gt;(na.NodeType == ExpressionType.NewArrayInit)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.NewArrayInit(na.Type.GetElementType(), exprs);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue"&gt;else&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.NewArrayBounds(na.Type.GetElementType(), exprs);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;na;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected virtual &lt;/span&gt;Expression VisitInvocation(InvocationExpression iv)&lt;br /&gt;    {&lt;br /&gt;        IEnumerable&amp;lt;Expression&amp;gt; args = &lt;span style="color: blue"&gt;this&lt;/span&gt;.VisitExpressionList(iv.Arguments);&lt;br /&gt;        Expression expr = &lt;span style="color: blue"&gt;this&lt;/span&gt;.Visit(iv.Expression);&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(args != iv.Arguments || expr != iv.Expression)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;Expression.Invoke(expr, args);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;iv;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;Original post can be found &lt;a href="http://blogs.msdn.com/mattwar/archive/2007/07/31/linq-building-an-iqueryable-provider-part-ii.aspx" target="_blank"&gt;here&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-5278680549287073254?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/3nIv5ODuqjk" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5278680549287073254" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5278680549287073254" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/3nIv5ODuqjk/linq-building-iqueryable-provider-part.html" title="LINQ: Building an IQueryable Provider - Part II" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/09/linq-building-iqueryable-provider-part.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-1877839721922985533</id><published>2009-08-20T01:46:00.001-07:00</published><updated>2009-09-02T20:47:19.676-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="Object Relational" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="LINQ" /><category scheme="http://www.blogger.com/atom/ns#" term="Code" /><title type="text">LINQ: Building an IQueryable Provider - Part I</title><content type="html">&lt;p&gt;I’ve been meaning for a while to start up a series of posts that covers building LINQ providers using IQueryable. People have been asking me advice on doing this for quite some time now, whether through internal Microsoft email or questions on the forums or by cracking the encryption and mailing me directly. Of course, I’ve mostly replied with “I’m working on a sample that will show you everything” letting them know that soon all will be revealed. However, instead of just posting a full sample here I felt it prudent to go step by step so I can actual dive deep and explain everything that is going on instead of just dumping it all in your lap and letting you find your own way.  &lt;p&gt;The first thing I ought to point out to you is that IQueryable has changed in Beta 2. It’s no longer just one interface, having been factored into two: IQueryable and IQueryProvider. Let’s just walk through these before we get to actually implementing them.  &lt;p&gt;If you use Visual Studio to ‘go to definition’ you get something that looks like this:  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IQueryable &lt;/span&gt;: IEnumerable&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    Type ElementType { &lt;span style="color: blue"&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;    Expression Expression { &lt;span style="color: blue"&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;    IQueryProvider Provider { &lt;span style="color: blue"&gt;get&lt;/span&gt;; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IQueryable&lt;/span&gt;&amp;lt;T&amp;gt; : IEnumerable&amp;lt;T&amp;gt;, &lt;span style="color: #2b91af"&gt;IQueryable&lt;/span&gt;, IEnumerable&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Of course, IQueryable no longer looks all that interesting; the good stuff has been pushed off into the new interface IQueryProvider. Yet before I get into that, IQueryable is still worth looking at. As you can see the only things IQueryable has are three read-only properties. The first one gives you the element type (or the ‘T’ in IQueryable&amp;lt;T&amp;gt;). It’s important to note that all classes that implement IQueryable must also implement IQueryable&amp;lt;T&amp;gt; for some T and vice versa. The generic IQueryable&amp;lt;T&amp;gt; is the one you use most often in method signatures and the like. The non-generic IQueryable exist primarily to give you a weakly typed entry point primarily for dynamic query building scenarios. &lt;br /&gt;&lt;p&gt;The second property gives you the expression that corresponds to the query. This is quintessential essence of IQueryable’s being. The actual ‘query’ underneath the hood of an IQueryable is an expression that represents the query as a tree of LINQ query operators/method calls. This is the part of the IQueryable that your provider must comprehend in order to do anything useful. If you look deeper you will see that the whole IQueryable infrastructure (including the System.Linq.Queryable version of LINQ standard query operators) is just a mechanism to auto-construct expression tree nodes for you. When you use the Queryable.Where method to apply a filter to an IQueryable, it simply builds you a new IQueryable adding a method-call expression node on top of the tree representing the call you just made to Queryable.Where. Don’t believe me? Try it yourself and see what it does. &lt;br /&gt;&lt;p&gt;Now that just leaves us with the last property that gives us an instance of this new interface IQueryProvider. What we’ve done is move all the methods that implement constructing new IQueryables and executing them off into a separate interface that more logically represents your true provider.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public interface &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IQueryProvider&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;    IQueryable CreateQuery(Expression expression);&lt;br /&gt;&lt;br /&gt;    IQueryable&amp;lt;TElement&amp;gt; CreateQuery&amp;lt;TElement&amp;gt;(Expression expression);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;object &lt;/span&gt;Execute(Expression expression);&lt;br /&gt;&lt;br /&gt;    TResult Execute&amp;lt;TResult&amp;gt;(Expression expression);&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Looking at the IQueryProvider interface you might be thinking, “why all these methods?” The truth is that there are really only two operations, CreateQuery and Execute, we just have both a generic and a non-generic form of each. The generic forms are used most often when you write queries directly in the programming language and perform better since we can avoid using reflection to construct instances. &lt;br /&gt;&lt;p&gt;The CreateQuery method does exactly what it sounds like it does. It creates a new instance of an IQueryable query based on the specified expression tree. When someone calls this method they are basically asking your provider to build a new instance of an IQueryable that when enumerated will invoke your query provider and process this specific query expression. The Queryable form of the standard query operators use this method to construct new IQueryable’s that stay associated with your provider. Note the caller can pass any expression tree possible to this API. It may not even be a legal query for your provider. However, the only thing that must be true is that expression itself must be typed to return/produce a correctly typed IQueryable. You see the IQueryable contains an expression that represents a snippet of code that if turned into actual code and executed would reconstruct that very same IQueryable (or its equivalent). &lt;br /&gt;&lt;p&gt;The Execute method is the entry point into your provider for actually executing query expressions. Having an explicit execute instead of just relying on IEnumerable.GetEnumerator() is important because it allows execution of expressions that do not necessarily yield sequences. For example, the query “myquery.Count()” returns a single integer. The expression tree for this query is a method call to the Count method that returns the integer. The Queryable.Count method (as well as the other aggregates and the like) use this method to execute the query ‘right now’. &lt;br /&gt;&lt;p&gt;There, that doesn’t seem so frightening does it? You could implement all those methods easily, right? Sure you could, but why bother. I’ll do it for you. Well all except for the execute method. I’ll show you how to do that in a later post. &lt;br /&gt;&lt;p&gt;First let’s start with the IQuerayble. Since this interface has been split into two, it’s now possible to implement the IQueryable part just once and re-use it for any provider. I’ll implement a class called Query&amp;lt;T&amp;gt; that implements IQueryable&amp;lt;T&amp;gt; and all the rest. &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Query&lt;/span&gt;&amp;lt;T&amp;gt; : IQueryable&amp;lt;T&amp;gt;, IQueryable, IEnumerable&amp;lt;T&amp;gt;, IEnumerable, IOrderedQueryable&amp;lt;T&amp;gt;, IOrderedQueryable&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    QueryProvider provider;&lt;br /&gt;&lt;br /&gt;    Expression expression;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;Query(QueryProvider provider)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(provider == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;ArgumentNullException(&lt;span style="color: #a31515"&gt;"provider"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.provider = provider;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.expression = Expression.Constant(&lt;span style="color: blue"&gt;this&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;Query(QueryProvider provider, Expression expression)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(provider == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;ArgumentNullException(&lt;span style="color: #a31515"&gt;"provider"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(expression == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;ArgumentNullException(&lt;span style="color: #a31515"&gt;"expression"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(!&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(IQueryable&amp;lt;T&amp;gt;).IsAssignableFrom(expression.Type))&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;throw new &lt;/span&gt;ArgumentOutOfRangeException(&lt;span style="color: #a31515"&gt;"expression"&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.provider = provider;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;this&lt;/span&gt;.expression = expression;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Expression IQueryable.Expression&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return this&lt;/span&gt;.expression; }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Type IQueryable.ElementType&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return typeof&lt;/span&gt;(T); }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    IQueryProvider IQueryable.Provider&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;get &lt;/span&gt;{ &lt;span style="color: blue"&gt;return this&lt;/span&gt;.provider; }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public &lt;/span&gt;IEnumerator&amp;lt;T&amp;gt; GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;((IEnumerable&amp;lt;T&amp;gt;)&lt;span style="color: blue"&gt;this&lt;/span&gt;.provider.Execute(&lt;span style="color: blue"&gt;this&lt;/span&gt;.expression)).GetEnumerator();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    IEnumerator IEnumerable.GetEnumerator()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;((IEnumerable)&lt;span style="color: blue"&gt;this&lt;/span&gt;.provider.Execute(&lt;span style="color: blue"&gt;this&lt;/span&gt;.expression)).GetEnumerator();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public override string &lt;/span&gt;ToString()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.provider.GetQueryText(&lt;span style="color: blue"&gt;this&lt;/span&gt;.expression);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;As you can see now, the IQueryable implementation is straightforward. This little object really does just hold onto an expression tree and a provider instance. The provider is where it really gets juicy. &lt;br /&gt;&lt;p&gt;Okay, now I need some provider to show you. I’ve implemented an abstract base class called QueryProvider that Query&amp;lt;T&amp;gt; referred to above. A real provider can just derive from this class and implement the Execute method.&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public abstract class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;QueryProvider &lt;/span&gt;: IQueryProvider&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;protected &lt;/span&gt;QueryProvider()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    IQueryable&amp;lt;S&amp;gt; IQueryProvider.CreateQuery&amp;lt;S&amp;gt;(Expression expression)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return new &lt;/span&gt;Query&amp;lt;S&amp;gt;(&lt;span style="color: blue"&gt;this&lt;/span&gt;, expression);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    IQueryable IQueryProvider.CreateQuery(Expression expression)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        Type elementType = TypeSystem.GetElementType(expression.Type);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;try&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;(IQueryable)Activator.CreateInstance(&lt;span style="color: blue"&gt;typeof&lt;/span&gt;(Query&amp;lt;&amp;gt;).MakeGenericType(elementType), &lt;span style="color: blue"&gt;new object&lt;/span&gt;[] { &lt;span style="color: blue"&gt;this&lt;/span&gt;, expression });&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;catch &lt;/span&gt;(TargetInvocationException tie)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;throw &lt;/span&gt;tie.InnerException;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    S IQueryProvider.Execute&amp;lt;S&amp;gt;(Expression expression)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;(S)&lt;span style="color: blue"&gt;this&lt;/span&gt;.Execute(expression);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;object &lt;/span&gt;IQueryProvider.Execute(Expression expression)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.Execute(expression);&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public abstract string &lt;/span&gt;GetQueryText(Expression expression);&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;public abstract object &lt;/span&gt;Execute(Expression expression);&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;I’ve implemented the IQueryProvider interface on my base class QueryProvider. The CreateQuery methods create new instances of Query&amp;lt;T&amp;gt; and the Execute methods forward execution to this great new and not-yet-implemented Execute method. &lt;br /&gt;&lt;p&gt;I suppose you can think of this as boilerplate code you have to write just to get started building a LINQ IQueryable provider. The real action happens inside the Execute method. That’s where your provider has the opportunity to make sense of the query by examining the expression tree. &lt;br /&gt;&lt;p&gt;And that’s what I’ll start showing next time. &lt;br /&gt;&lt;p&gt;UPDATE: &lt;br /&gt;&lt;p&gt;It looks like I’ve forget to define a little helper class my implementation was using, so here it is:&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;internal static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TypeSystem&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;internal static &lt;/span&gt;Type GetElementType(Type seqType)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        Type ienum = FindIEnumerable(seqType);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(ienum == &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;span style="color: blue"&gt;return &lt;/span&gt;seqType;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return &lt;/span&gt;ienum.GetGenericArguments()[0];&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private static &lt;/span&gt;Type FindIEnumerable(Type seqType)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(seqType == &lt;span style="color: blue"&gt;null &lt;/span&gt;|| seqType == &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;))&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(seqType.IsArray)&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return typeof&lt;/span&gt;(IEnumerable&amp;lt;&amp;gt;).MakeGenericType(seqType.GetElementType());&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(seqType.IsGenericType)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(Type arg &lt;span style="color: blue"&gt;in &lt;/span&gt;seqType.GetGenericArguments())&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                Type ienum = &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(IEnumerable&amp;lt;&amp;gt;).MakeGenericType(arg);&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;(ienum.IsAssignableFrom(seqType))&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    &lt;span style="color: blue"&gt;return &lt;/span&gt;ienum;&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        Type[] ifaces = seqType.GetInterfaces();&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(ifaces != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; ifaces.Length &amp;gt; 0)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(Type iface &lt;span style="color: blue"&gt;in &lt;/span&gt;ifaces)&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                Type ienum = FindIEnumerable(iface);&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;if &lt;/span&gt;(ienum != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &lt;span style="color: blue"&gt;return &lt;/span&gt;ienum;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(seqType.BaseType != &lt;span style="color: blue"&gt;null &lt;/span&gt;&amp;amp;&amp;amp; seqType.BaseType != &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;object&lt;/span&gt;))&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;FindIEnumerable(seqType.BaseType);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;return null&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Yah, I know. There’s more ‘code’ in this helper than in all the rest. Sigh. J &lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://blogs.msdn.com/mattwar/archive/2007/07/30/linq-building-an-iqueryable-provider-part-i.aspx" target="_blank"&gt;here&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/1002597578696693985-1877839721922985533?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/AYhlAifwFps" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1877839721922985533" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1877839721922985533" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/AYhlAifwFps/linq-building-iqueryable-provider-part.html" title="LINQ: Building an IQueryable Provider - Part I" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/linq-building-iqueryable-provider-part.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-6969622616115917380</id><published>2009-08-16T22:09:00.001-07:00</published><updated>2009-08-16T22:12:26.231-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="typeof" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET Reflection" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="Reflection" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Singleton" /><title type="text">A Defense of Reflection in .NET</title><content type="html">&lt;p&gt;&lt;img alt="Nick Harrison" src="http://www.simple-talk.com/iwritefor/publishers/141.gif" align="left"&gt; &lt;p&gt;A Defense of Reflection in .NET &lt;p&gt;13 August 2009 &lt;p&gt;by &lt;a href="http://www.simple-talk.com/author/nick-harrison/"&gt;Nick Harrison&lt;/a&gt; &lt;p&gt;The trouble with making general rules about programming practices is that one can miss out on many benefits of of a framework by following them too literally in every context. Everyone knows that one should watch for performance problems and security issues with reflection. It doesn't mean you shouldn't it, it just means you must test carefully, monitor performance, and assess risks. Nick Harrison illustrates the theme with a practical example.  &lt;h3&gt;Introduction&lt;/h3&gt; &lt;p&gt;Reflection is one of the great marvels of modern programming environments.&amp;nbsp;&amp;nbsp; Being able to store meta data about our code, and retrieve it at run time, opens up a world of possibilities.&amp;nbsp;&amp;nbsp; Many developers and software designers have embraced reflection and sing its praises, but reflection is not without its critics. &lt;p&gt;Here we will explore some of the criticism of reflection, debunk some of the myths around its usage, and explore the benefits through some practical applications. &lt;h3&gt;What's Wrong With Reflection&lt;/h3&gt; &lt;p&gt;There are various complaints and cautionary warnings against using reflection.&amp;nbsp; Some of these are valid risks that we need to be aware of;&amp;nbsp; others are wild tales based on early-adopters not understanding what they were using.&amp;nbsp; Some are valid only in certain circumstances, or valid in all but special cases.&amp;nbsp; Here we will explore some of these complaints.&amp;nbsp;&amp;nbsp; You should always be wary of a technology that is new or not well understood, but do not let that stand in the way of making appropriate use of technology. &lt;h4&gt;Performance&lt;/h4&gt; &lt;p&gt;Everyone knows that reflection is slow.&amp;nbsp;&amp;nbsp; The web is full of well meaning warnings that one should not use Reflection if you care about performance.&amp;nbsp;&amp;nbsp; Retrieving the meta-data slows your application down: One is often reading advice that, If you care about performance, you should never use reflection.&amp;nbsp;&amp;nbsp; &lt;p&gt;This is a legitimate concern that should be taken seriously, but this is not a carte blanche reason not to ever use Reflection. &lt;p&gt;While you should always worry about performance, you should not let performance worries keep you from making appropriate use of new technology.&amp;nbsp;&amp;nbsp; Do your own timing studies in your own environment.&amp;nbsp; If there are performance issues, there are ways to minimize the performance impact. &lt;p&gt;The DotNet framework itself uses reflection extensively.&amp;nbsp; Reflection is being used whether we intend to or not.&amp;nbsp;&amp;nbsp; Take a look at the details in the &lt;b&gt;Machine.Config&lt;/b&gt; file.&amp;nbsp; Almost all that you see is providing details to open an Assembly and load a Type with Reflection to make the framework itself work.&amp;nbsp; The DotNet framework is all about Reflection. &lt;p&gt;If performance worries still nag you, there are tweaks that you can make in your own code to improve performance. &lt;p&gt;If you are going to make repeated calls to the Properties of an object, cache the Properties in a Hash Table.&amp;nbsp; Reference the hash table instead of repeated calls to &lt;b&gt;GetProperty&lt;/b&gt; or &lt;b&gt;GetProperties&lt;/b&gt;.&amp;nbsp; The same is true for Methods, Types and Assemblies. &lt;p&gt;Get comfortable with the &lt;b&gt;BindingFlags&lt;/b&gt; enumeration.&amp;nbsp; Always specify &lt;b&gt;BindingFlags&lt;/b&gt;.&amp;nbsp; Never use the &lt;b&gt;IgnoreCase&lt;/b&gt; flag.&amp;nbsp; Limit the searches to Public.&amp;nbsp;&amp;nbsp; Limit the searches to Static or Instance as appropriate. &lt;p&gt;Don't just assume that performance will suffer.&amp;nbsp;&amp;nbsp; Embrace Reflection, but test it.&amp;nbsp;&amp;nbsp; There are various profiling tools, such as Red Gate's Ants Profiler.&amp;nbsp;&amp;nbsp; Use them to identify the true cause of a performance problem.&amp;nbsp;&amp;nbsp; If Reflection is the right tool, don't ignore it simply because someone told you that it will be slow.&amp;nbsp; If it turns out be too slow for you, there are ways to optimize its usage. &lt;h4&gt;Security&lt;/h4&gt; &lt;p&gt;Reflection, it is said,&amp;nbsp; poses an unacceptable security risk.&amp;nbsp;&amp;nbsp; The essence of most designs that leverage Reflection also incorporate the process of dynamically discovering new code and executing it.&amp;nbsp;&amp;nbsp; This opens up a risk that malicious code will be executing and compromising the entire system. &lt;p&gt;In the modern world of Malware and security threats, we are all concerned about security.&amp;nbsp;&amp;nbsp; The risk with Reflection is that malicious code may be substituted for your own code.&amp;nbsp;&amp;nbsp; Many reflective designs do, indeed, rely on loading new assemblies, discovering new types, and running discovered methods and properties on these new types.&amp;nbsp; While this may lead many to steer clear of a reflective solution, don't run scared. &lt;p&gt;An intruder would need to physically place malicious code where your reflective code can find it.&amp;nbsp;&amp;nbsp; While this is not impossible, a good defense in depth design can mitigate this risk.&amp;nbsp;&amp;nbsp; Properly configured firewalls with processing servers behind the firewalls will help.&amp;nbsp; Intrusion detection will alert administrators to servers that are being targeted, and properly patched servers will help eliminate known vulnerabilities. &lt;p&gt;Code Access Security, properly configured, can also limit the access that reflective code has.&amp;nbsp;&amp;nbsp; With Code Access Security, individual assemblies can run with fewer rights than the user running the assembly. &lt;p&gt;This article is not about configuring security settings but rather to assure you that there are counter measures to any security concern that you may have. &lt;h4&gt;Confusion&lt;/h4&gt; &lt;p&gt;Reflective code, so one hears,&amp;nbsp; is very hard to follow.&amp;nbsp;&amp;nbsp; Developers new to the project will have difficulty learning the ropes.&amp;nbsp; Anything that steepens the learning curve jeopardizes project time lines and should be avoided.&amp;nbsp; If only a select group of developers can understand the reflective code then the project is overly dependent on this select group, and is doomed to fail. &lt;p&gt;This is also not a very legitimate concern.&amp;nbsp;&amp;nbsp; If every design decision is based on what the least experienced programmer can readily understand, our designs will be severely limited.&amp;nbsp;&amp;nbsp; Reflective code can, and should, be isolated.&amp;nbsp;&amp;nbsp; Daily development should not be modifying this code.&amp;nbsp;&amp;nbsp; Daily development should use the reflective methods to simplify daily development tasks.&amp;nbsp; &lt;p&gt;We want our code to be easy to follow, and Reflective code is not always the most intuitive code to understand at first glance.&amp;nbsp;&amp;nbsp;&amp;nbsp; Without a doubt the hard-coded option is easier to follow than the reflective version &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Hard Coded&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public void &lt;/span&gt;MapData(IEmployee first, IEmployee second)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    second.FirstName = first.FirstName;&lt;br /&gt;&lt;br /&gt;    second.Address = first.Address;&lt;br /&gt;&lt;br /&gt;    second.BranchLocation = first.BranchLocation;&lt;br /&gt;&lt;br /&gt;. . .&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Reflective&lt;/strong&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static void &lt;/span&gt;MapData(&lt;span style="color: blue"&gt;object &lt;/span&gt;sourceObject,&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;object &lt;/span&gt;targetObject)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;object&lt;/span&gt;[] value = &lt;span style="color: blue"&gt;new object&lt;/span&gt;[1];&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;object&lt;/span&gt;[] param = &lt;span style="color: blue"&gt;new object&lt;/span&gt;[0];&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(PropertyInfo propertyInfo&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;in &lt;/span&gt;sourceObject.GetType().GetProperties())&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        PropertyInfo targetPropertyInfo =&lt;br /&gt;&lt;br /&gt;            targetObject.GetType().&lt;br /&gt;&lt;br /&gt;            GetProperty(propertyInfo.Name);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(targetPropertyInfo.CanWrite)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            value[0] = propertyInfo.GetValue(sourceObject,&lt;br /&gt;&lt;br /&gt;                BindingFlags.Public, &lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;            targetPropertyInfo.SetValue&lt;br /&gt;&lt;br /&gt;                (targetObject, value,&lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Anyone can look at the hard-coded version and immediately tell what is going on.&amp;nbsp;&amp;nbsp; The reflective version will probably take a senior developer a second look to figure out.&lt;br /&gt;&lt;p&gt;However, the hard-coded version is tedious code.&amp;nbsp; Depending on the number of properties being mapped, more and more errors are likely to be introduced.&amp;nbsp; In the long run, this results in&amp;nbsp; more code that has to be hand written.&lt;br /&gt;&lt;p&gt;While the reflective code may be hard to follow, it does not need to be referenced very often to be useful.&lt;br /&gt;&lt;p&gt;With the hard-coded implementation, you have to write a similar method for every type that you want to map.&amp;nbsp; This is a tedious proposition indeed!&amp;nbsp;&amp;nbsp; With the reflective implementation, this one method can handle the process of mapping any object in your system.&lt;br /&gt;&lt;p&gt;For the observant reader, this is far from the most optimized implementation for the reflective version.&amp;nbsp; We will go over the reflective version in more detail later and discuss various ways to optimize.&lt;br /&gt;&lt;h3&gt;Why Use Reflection?&lt;/h3&gt;&lt;br /&gt;&lt;h4&gt;Developer Performance&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;As mentioned earlier, the hard coded version is often tedious, and tedious code is often error-prone.&lt;br /&gt;&lt;p&gt;You can well imagine the potential for introducing bugs by having to iterate through, and explicitly set, each property in an object. This can quickly get out of hand.&amp;nbsp;&amp;nbsp; Bugs from assigning the wrong value to the wrong property are easy to introduce and difficult to track down.&lt;br /&gt;&lt;p&gt;It is much easier to write a single line of code to handle the mapping and then move on to more important tasks such as implementing business logic and meeting deadlines.&lt;br /&gt;&lt;p&gt;A call like DataMapper.CopyTo (data, ui) is easy to understand and quick to write.&amp;nbsp;&amp;nbsp; As long as the property names match and are of the same types, you don't have to worry about missing any assignments.&amp;nbsp;&amp;nbsp; As a developer, you implement a series of rather simple properties to handle validation, and you don't have to get bogged down in the details of the mapping logic.&lt;br /&gt;&lt;h4&gt;Stability / Consistency&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;Not everyone will get reflective code right the first time, but this is the beauty of consistency.&amp;nbsp; If the implementation that everyone is using is inefficient or has a logic problem, you have only to correct it in one place.&amp;nbsp;&amp;nbsp; If there are multiple hard coded implementations, some will, no doubt, be done as efficiently as possible.&amp;nbsp;&amp;nbsp; Some will, to be sure, be free from all logic problems, but at least some implementations will have problems that will need to be addressed.&lt;br /&gt;&lt;p&gt;Reflective code is much easier to reuse.&amp;nbsp;&amp;nbsp; If the code is widely reused, then we have fewer places to correct when there is a problem found.&lt;br /&gt;&lt;p&gt;This consistency improves the overall stability of the system.&lt;br /&gt;&lt;h3&gt;Practical Applications&lt;/h3&gt;&lt;br /&gt;&lt;h4&gt;Tweaking Performance &lt;/h4&gt;&lt;br /&gt;&lt;p&gt;Performance is always a concern.&amp;nbsp;&amp;nbsp; There are some simple steps that we can take to eke&amp;nbsp; the best performance out of our reflective code.&lt;br /&gt;&lt;p&gt;Whenever you make a Reflection call, make it count.&amp;nbsp; Cache the output so that it can be reused.&amp;nbsp;&amp;nbsp; Calls to &lt;b&gt;GetProperty&lt;/b&gt;, &lt;b&gt;LoadAssembly&lt;/b&gt; or &lt;b&gt;GetType&lt;/b&gt; are expensive.&amp;nbsp;&amp;nbsp; If there is any chance that you are going to need a method or a property more than once, store the return value so that you can use it later without having to make the call again.&amp;nbsp;&amp;nbsp; &lt;p&gt;This is also an example where multi threading can give you the perception of performance improvement.&amp;nbsp;&amp;nbsp; This proves to be a nice option for batch application and for business / data servers.&amp;nbsp;&amp;nbsp; This does not provide any benefit for the web UI, but can be very beneficial for a traditional windows application.&lt;br /&gt;&lt;h4&gt;CopyTo&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;CopyTo&lt;/b&gt; is the reflective MapData that we saw earlier.&amp;nbsp;&amp;nbsp; Let's discuss some strategies to get the basic method ready for prime-time.&amp;nbsp;&amp;nbsp; As we stated earlier, we don't want to throw away the return value of the &lt;b&gt;GetProperty&lt;/b&gt; call.&amp;nbsp;&amp;nbsp; We also want to avoid calling &lt;b&gt;GetProperty&lt;/b&gt; altogether when we are truly interested in every property.&lt;br /&gt;&lt;p&gt;We start by checking to see if our collection of properties has already been loaded into a hash table.&amp;nbsp; If they have, then we use this previously-loaded list.&amp;nbsp;&amp;nbsp; If not, we go ahead and load the details into the hash table.&amp;nbsp; This will allow us to avoid the &lt;b&gt;GetProperty&lt;/b&gt; calls altogether.&amp;nbsp;&amp;nbsp; If we are copying from one object to another of the same type, we dramatically reduce the number of reflection calls.&amp;nbsp; If we call this method multiple times with the same set of objects, we reduce the reflective even more.&lt;br /&gt;&lt;p&gt;Our caching logic could look similar to this:&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;Hashtable properties;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;private &lt;/span&gt;Hashtable Properties&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: blue"&gt;get&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: blue"&gt;if &lt;/span&gt;(properties == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;          properties = &lt;span style="color: blue"&gt;new &lt;/span&gt;Hashtable();&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: blue"&gt;return &lt;/span&gt;properties;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;LoadProperties(&lt;span style="color: blue"&gt;object &lt;/span&gt;targetObject, Type targetType)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;if &lt;/span&gt;(properties[targetType.FullName] != &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        List&amp;lt;PropertyInfo&amp;gt; propertyList = &lt;span style="color: blue"&gt;new &lt;/span&gt;List&amp;lt;PropertyInfo&amp;gt;();&lt;br /&gt;&lt;br /&gt;        PropertyInfo[] objectProperties =&lt;br /&gt;&lt;br /&gt;            targetType.GetProperties(BindingFlags.Public);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(PropertyInfo currentProperty &lt;span style="color: blue"&gt;in &lt;/span&gt;objectProperties)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            propertyList.Add(currentProperty);&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        properties[targetObject] = propertyList;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Here we first check to see if the Hash table already has a list of properties for our object.&amp;nbsp;&amp;nbsp; If it does then we have nothing to do.&amp;nbsp;&amp;nbsp; If not, we load the properties into a generic list to be added to the hash table.&lt;br /&gt;&lt;p&gt;Our optimized &lt;b&gt;CopyTo &lt;/b&gt;function can now be rewritten as:&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public  void &lt;/span&gt;CopyTo(&lt;span style="color: blue"&gt;object &lt;/span&gt;sourceObject, &lt;span style="color: blue"&gt;object &lt;/span&gt;targetObject)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: blue"&gt;object&lt;/span&gt;[] value = &lt;span style="color: blue"&gt;new object&lt;/span&gt;[1];&lt;br /&gt;&lt;br /&gt;  Type sourceType = sourceObject.GetType();&lt;br /&gt;&lt;br /&gt;  Type targetType = targetObject.GetType();&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  LoadProperties(sourceObject, sourceType);&lt;br /&gt;&lt;br /&gt;  LoadProperties(targetObject, targetType);&lt;br /&gt;&lt;br /&gt;  List&amp;lt;PropertyInfo&amp;gt; sourcePoperties =&lt;br /&gt;&lt;br /&gt;      Properties[sourceType.FullName] &lt;span style="color: blue"&gt;as &lt;/span&gt;List&amp;lt;PropertyInfo&amp;gt;;&lt;br /&gt;&lt;br /&gt;  List&amp;lt;PropertyInfo&amp;gt; targetProperties =&lt;br /&gt;&lt;br /&gt;      Properties[targetType.FullName] &lt;span style="color: blue"&gt;as &lt;/span&gt;List&amp;lt;PropertyInfo&amp;gt;;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(PropertyInfo sourceProperty &lt;span style="color: blue"&gt;in &lt;/span&gt;sourcePoperties)&lt;br /&gt;&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;      PropertyInfo targetPropertyInfo = targetProperties.&lt;br /&gt;&lt;br /&gt;          Find(&lt;span style="color: blue"&gt;delegate&lt;/span&gt;(PropertyInfo prop)&lt;br /&gt;&lt;br /&gt;           { &lt;span style="color: blue"&gt;return &lt;/span&gt;prop.Name == sourceProperty.Name ; });&lt;br /&gt;&lt;br /&gt;      &lt;span style="color: blue"&gt;if &lt;/span&gt;(sourceProperty.CanRead)&lt;br /&gt;&lt;br /&gt;      {&lt;br /&gt;&lt;br /&gt;          &lt;span style="color: blue"&gt;if &lt;/span&gt;(targetPropertyInfo.CanWrite)&lt;br /&gt;&lt;br /&gt;          {&lt;br /&gt;&lt;br /&gt;              value[0] = sourceProperty.GetValue(sourceObject,&lt;br /&gt;&lt;br /&gt;                    BindingFlags.Public, &lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;, &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;              targetPropertyInfo.SetValue&lt;br /&gt;&lt;br /&gt;                  (targetObject, value, &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;The biggest change we have here is in the calls to the &lt;b&gt;LoadProperties&lt;/b&gt; method.&amp;nbsp;&amp;nbsp; If the properties are already loaded, this will have no effect.&amp;nbsp;&amp;nbsp; If they are not, this method will load the properties for us.&amp;nbsp; Once our properties are loaded into the hash table, we can safely pull them out of the generic list instead of making repeated calls to &lt;b&gt;GetProperties&lt;/b&gt; or &lt;b&gt;GetProperty&lt;/b&gt;.&lt;br /&gt;&lt;p&gt;Once we have our two properties, we make sure that the source can be read and that the target can be written to.&amp;nbsp;&amp;nbsp; Now we simply “get” the value from the source and “set” the value on the target.&lt;br /&gt;&lt;h4&gt;MapDataToBusinessEntityCollection&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;MapDataToBusinessEntityCollection&lt;/b&gt; is a generic Reflective method.&amp;nbsp; We pass in the data-type for the objects to be mapped as a generic parameter along with a data reader.&amp;nbsp;&amp;nbsp; We use reflection to find the properties in this type and we use the meta data in the DataReader to find the fields.&lt;br /&gt;&lt;p&gt;Whenever we find a field from the data reader that has a matching writable property in the generic type, we pull the value from the DataReader and assign it to a newly created object.&amp;nbsp;&amp;nbsp; Regardless of how many properties are in T, this method will map every property that has a matching field in the DataReader.&amp;nbsp; Any properties that are not in the DataReader will be unmapped.&amp;nbsp; Any fields in the data reader that do not have a matching property will be ignored.&amp;nbsp;&amp;nbsp; The validation logic is handled in the implementation of the properties in T.&lt;br /&gt;&lt;p&gt;&lt;span style="color: blue"&gt;public static&lt;/span&gt;List&amp;lt;T&amp;gt; MapDataToBusinessEntityCollection&amp;lt;T&amp;gt;&lt;br&gt;&lt;br&gt;(IDataReader dr)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; where T : &lt;span style="color: blue"&gt;new&lt;/span&gt;()&lt;br&gt;&lt;br&gt;{&lt;br&gt;&lt;br&gt;&amp;nbsp; Type businessEntityType = &lt;span style="color: blue"&gt;typeof &lt;/span&gt;(T);&lt;br&gt;&lt;br&gt;&amp;nbsp; List&amp;lt;T&amp;gt; entitys = &lt;span style="color: blue"&gt;new&lt;/span&gt;List&amp;lt;T&amp;gt;();&lt;br&gt;&lt;br&gt;&amp;nbsp; Hashtable hashtable = &lt;span style="color: blue"&gt;new&lt;/span&gt;Hashtable();&lt;br&gt;&lt;br&gt;&amp;nbsp; PropertyInfo[] properties = businessEntityType.GetProperties();&lt;br&gt;&lt;br&gt;&amp;nbsp; &lt;span style="color: blue"&gt;foreach &lt;/span&gt;(PropertyInfo info &lt;span style="color: blue"&gt;in&lt;/span&gt;properties)&lt;br&gt;&lt;br&gt;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hashtable[info.Name.ToUpper()] = info;&lt;br&gt;&lt;br&gt;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp; &lt;span style="color: blue"&gt;while&lt;/span&gt;(dr.Read())&lt;br&gt;&lt;br&gt;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T newObject = &lt;span style="color: blue"&gt;new&lt;/span&gt;T();&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;index = 0; index &amp;lt; dr.FieldCount; index++)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PropertyInfo info = (PropertyInfo)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hashtable[dr.GetName(index).ToUpper()];&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue"&gt;if&lt;/span&gt;((info != &lt;span style="color: blue"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; info.CanWrite)&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; info.SetValue(newObject, dr.GetValue(index), &lt;span style="color: blue"&gt;null&lt;/span&gt;);&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entitys.Add(newObject);&lt;br&gt;&lt;br&gt;&amp;nbsp; }&lt;br&gt;&lt;br&gt;&amp;nbsp; dr.Close();&lt;br&gt;&lt;br&gt;&amp;nbsp; &lt;span style="color: blue"&gt;return&lt;/span&gt;entitys;&lt;br&gt;&lt;br&gt;}&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Timing Studies&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;To evaluate the performance implications of this approach, I set up a test-bed to perform my own timing studies.&amp;nbsp;&amp;nbsp; An ounce of testing is worth a pound of speculation. &lt;br /&gt;&lt;p&gt;In my test-bed, I defined an object to encapsulate the Employee table in the NorthWinds database.&amp;nbsp;&amp;nbsp; I loaded this table with 100,000 records and timed how long it took to retrieve records using various methods.&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_AobfMhNy_Xo/Sojl63a3iEI/AAAAAAAAAD8/cvfSYddBylk/s1600-h/777-ADefen1%5B8%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="520" alt="777-ADefen1" src="http://lh5.ggpht.com/_AobfMhNy_Xo/Sojl785xTfI/AAAAAAAAAEA/gN-xYjYGLUc/777-ADefen1_thumb%5B6%5D.jpg?imgmax=800" width="662" border="0"&gt;&lt;/a&gt;&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Hardcoded,&lt;/strong&gt; is this case, is the worse way you can write a Hard-coded&amp;nbsp; implementation, but it is also an approach that I have commonly seen followed.&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;HardCoded()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  System.DateTime start = DateTime.Now;&lt;br /&gt;&lt;br /&gt;  System.Data.IDataReader dr = GetData(recordCount);&lt;br /&gt;&lt;br /&gt;  &lt;span style="color: blue"&gt;while &lt;/span&gt;(dr.Read())&lt;br /&gt;&lt;br /&gt;  {&lt;br /&gt;&lt;br /&gt;      CustomTypes.Employees newEmployee =&lt;br /&gt;&lt;br /&gt;          &lt;span style="color: blue"&gt;new &lt;/span&gt;CustomTypes.Employees();&lt;br /&gt;&lt;br /&gt;      newEmployee.Address = dr[&lt;span style="color: #a31515"&gt;"Address"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.BirthDate =&lt;br /&gt;&lt;br /&gt;          DateTime.Parse(dr[&lt;span style="color: #a31515"&gt;"BirthDate"&lt;/span&gt;].ToString());&lt;br /&gt;&lt;br /&gt;      newEmployee.City = dr[&lt;span style="color: #a31515"&gt;"City"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.Country = dr[&lt;span style="color: #a31515"&gt;"Country"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.EmployeeID = Int32.Parse(dr[&lt;span style="color: #a31515"&gt;"EmployeeID"&lt;/span&gt;].ToString());&lt;br /&gt;&lt;br /&gt;      newEmployee.Extension = dr[&lt;span style="color: #a31515"&gt;"Extension"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.FirstName = dr[&lt;span style="color: #a31515"&gt;"FirstName"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.HireDate = DateTime.Parse(dr[&lt;span style="color: #a31515"&gt;"HireDate"&lt;/span&gt;].ToString());&lt;br /&gt;&lt;br /&gt;      newEmployee.LastName = dr[&lt;span style="color: #a31515"&gt;"LastName"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.PostalCode = dr[&lt;span style="color: #a31515"&gt;"PostalCode"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.Region = dr[&lt;span style="color: #a31515"&gt;"Region"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.ReportsTo = Int32.Parse(dr[&lt;span style="color: #a31515"&gt;"ReportsTo"&lt;/span&gt;].ToString());&lt;br /&gt;&lt;br /&gt;      newEmployee.Title = dr[&lt;span style="color: #a31515"&gt;"Title"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      newEmployee.TitleOfCourtesy = dr[&lt;span style="color: #a31515"&gt;"TitleOfCourtesy"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;br /&gt;      pgbHardCodedConversion.Increment(1);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  dr.Close();&lt;br /&gt;&lt;br /&gt;  System.DateTime stop = DateTime.Now;&lt;br /&gt;&lt;br /&gt;  System.TimeSpan ts = &lt;span style="color: blue"&gt;new &lt;/span&gt;TimeSpan(stop.Ticks - start.Ticks);&lt;br /&gt;&lt;br /&gt;  lblHardCodedConvertedTime.Text = &lt;span style="color: #a31515"&gt;"Finished in "&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;+ ts.TotalMilliseconds + &lt;span style="color: #a31515"&gt;" milliseconds"&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;This has several obvious problems, but since it has to be re coded for every data reader, it will often be done poorly.&lt;br /&gt;&lt;p&gt;Reflective Singleton is the same method outlined above, but without caching the&lt;b&gt; PropertyInfo &lt;/b&gt;objects.&amp;nbsp;&amp;nbsp; Comparing the Reflective Singleton and the &lt;b&gt;ReflectiveBatch&lt;/b&gt; shows the benefits of caching the &lt;b&gt;PropertyInfo&lt;/b&gt; objects.&amp;nbsp;&amp;nbsp; I believe this to be a dramatic improvement.&lt;br /&gt;&lt;p&gt;Hard-Coded without Conversion is the same as the &lt;strong&gt;HardCoded&lt;/strong&gt; implementation but skips the extra &lt;strong&gt;ToString&lt;/strong&gt; and parsing operations which should never be performed anyway.&lt;br /&gt;&lt;p&gt;So why is the Reflective Batch implementation faster than the hard-coded version?&amp;nbsp;&amp;nbsp; Indexing into the DataReader by Name is also a slow operation.&amp;nbsp;&amp;nbsp; The Reflective implementation avoids this costly lookup.&lt;br /&gt;&lt;p&gt;Undoubtedly, caching the indexes into the DataReader will change the results.&amp;nbsp;&amp;nbsp; More properties in the test object will change the results, and there are probably more optimizations that could be done to the hard-coded implementation.&lt;br /&gt;&lt;p&gt;All of this reinforces the need to test in your own environment.&amp;nbsp; Test for yourself.&amp;nbsp;&amp;nbsp; You may be surprised that a reflective solution probably will not ruin performance, and it will shorten your time to market.&lt;br /&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Do not shy away from Reflection or any other technology just because of warnings that you hear.&amp;nbsp; Always verify that the warnings apply to your project.&amp;nbsp;&amp;nbsp; Often times, they will not.&lt;br /&gt;&lt;p&gt;If you are worried about performance concerns, don’t blindly follow someone else’s opinion.&amp;nbsp; Test it with your own application.&lt;br /&gt;&lt;p&gt;Above all don’t be afraid to learn something new!&lt;br /&gt;&lt;p&gt;&lt;a href="http://www.simple-talk.com/author/nick-harrison/"&gt;&lt;img alt="Nick Harrison" src="http://www.simple-talk.com/iwritefor/publishers/141.gif" align="left"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Author profile:&lt;/strong&gt; &lt;a href="http://www.simple-talk.com/author/nick-harrison/"&gt;Nick Harrison&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Nick Harrison is a Software Architect and .NET advocate in Columbia, SC. Nick has over 14 years experience in software developing, starting with Unix system programming and then progressing to the DotNet platform. You can read his blog as www.geekswithblogs.net/nharrison &lt;br /&gt;&lt;p&gt;&lt;a href="http://www.simple-talk.com/author/nick-harrison/"&gt;Search for other articles by Nick Harrison&lt;/a&gt;&lt;/p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-6969622616115917380?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/xyNM1LC17iU" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/6969622616115917380" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/6969622616115917380" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/xyNM1LC17iU/defense-of-reflection-in-net.html" title="A Defense of Reflection in .NET" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/defense-of-reflection-in-net.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-7119636981145773677</id><published>2009-08-16T21:00:00.001-07:00</published><updated>2009-08-16T21:00:25.043-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">Free ebook on C# 3.0</title><content type="html">&lt;p&gt;&lt;a href="http://www.albahari.com/pocketref/"&gt;&lt;img title="C# 3.0 Pocket Reference" height="122" alt="C# 3.0 Pocket Reference" src="http://www.red-gate.com/products/ants_performance_profiler/images/csharp3_ebook_cover.gif" width="74" border="0"&gt;&lt;/a&gt; &lt;p&gt;This book is for busy programmers who want a succinct and yet readable guide to C# 3.0 and LINQ. &lt;em&gt;&lt;br&gt;C# 3.0 Pocket Reference,&lt;/em&gt; written by Joseph and Ben Albahari, tells you exactly what you need to know, without long introductions or bloated samples. Boost your C# expertise and keep ahead of your peers! &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Boost your C# expertise:&lt;br&gt;&lt;a href="http://downloads.red-gate.com/ebooks/DotNet/Csharp3_Pocket_Reference_Second_Edition.zip"&gt;Download your free ebook here&lt;/a&gt;&lt;br&gt;and keep ahead of the game.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-7119636981145773677?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/k9KEp6yDJgk" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7119636981145773677" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7119636981145773677" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/k9KEp6yDJgk/free-ebook-on-c-30.html" title="Free ebook on C# 3.0" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/free-ebook-on-c-30.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-4347683015211839599</id><published>2009-08-12T21:53:00.001-07:00</published><updated>2009-08-13T00:46:16.731-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="VIEWSTATE" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Custom Persiter" /><title type="text">Custom Persister to store the state in a backend database</title><content type="html">&lt;p&gt;As requested in &lt;a href="http://forums.asp.net/t/1292429.aspx"&gt;this post&lt;/a&gt;, following is an example of a way to store viewstate in a database on the server instead of the hidden form field on the page. The form only maintains a guid that is used to retrieve saved viewstate from the DB. This can reduce bandwidth considerably if viewstate is something that you can't or don't want to disable completely. &lt;p&gt;The following code snippets are included: &lt;ul&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;SamplePageStatePersister.cs&lt;/strong&gt; - custom mechanism for loading and saving viewstate for the page.&lt;/p&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;SamplePageAdapter.cs&lt;/strong&gt; - returns a new instance of SamplePageStatePersister (this is enlisted by the App.Browser file).&lt;/p&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;App.Browser&lt;/strong&gt; - must be added to the web project and tells the web application to use our custom page adapter.&lt;/p&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;PageViewStateServices.cs&lt;/strong&gt; - handles the interaction with the database via stored procedures to optimise performance.&lt;/p&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;PageViewState.sql&lt;/strong&gt; - creates the table to hold the view state and the stored procedures to interact with the database. You will need to apply the appropriate permissions.&lt;/p&gt; &lt;li&gt; &lt;p&gt;&lt;strong&gt;CleanupPageViewState.sql&lt;/strong&gt; - deletes old view state to stop the database growing uncontrollably. Configure as a scheduled job and can be modified to extend or reduce the time window for view state being maintained in the database. Defaults to 4 hours.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;NOTE: &lt;/strong&gt;This current example will not work if you use Server.Transfer and carry across the form data in the transfer. In this case, the view state ID will be carried across too and then subsequent back navigation will result in an error. &lt;p&gt;&lt;strong&gt;SamplePageStatePersister.cs&lt;/strong&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Globalization;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Data;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Configuration;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Security;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.WebControls;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;---------------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;This class is the page state persister for the application.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;///&lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;Created by Jason Hill on 26/6/2007.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;---------------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SamplePageStatePersister &lt;/span&gt;: System.Web.UI.PageStatePersister&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;private &lt;/span&gt;Page _page;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;---------------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Constructor.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    /// &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;param name="page"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Page.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;SamplePageStatePersister(Page page)&lt;br /&gt;        : &lt;span style="color: blue"&gt;base&lt;/span&gt;(page)&lt;br /&gt;    {&lt;br /&gt;        _page = page;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Get the unique ID for the view state.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    /// &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------    &lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;    private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;GetViewStateID()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;string &lt;/span&gt;viewStateKey;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Get the ID from the request&lt;br /&gt;        &lt;/span&gt;viewStateKey = _page.Request[&lt;span style="color: #a31515"&gt;"__VIEWSTATEID"&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Assign a new ID if we don't have one in the request&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(viewStateKey))&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Use the ID from the request if it is valid, else assign a new ID&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;try&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;(viewStateKey);&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;catch &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;FormatException&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;.NewGuid();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Load the view state from persistent medium.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    /// &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public override void &lt;/span&gt;Load()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Load view state from DB&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: blue"&gt;string &lt;/span&gt;pageViewState = PageViewStateServices.GetByID(GetViewStateID());&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(pageViewState == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            ViewState = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;            ControlState = &lt;span style="color: blue"&gt;null&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: green"&gt;// Deserialize into a Pair of ViewState and ControlState objects&lt;br /&gt;            &lt;/span&gt;IStateFormatter formatter = StateFormatter;&lt;br /&gt;            Pair statePair = (Pair)formatter.Deserialize(pageViewState);&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: green"&gt;// Update ViewState and ControlState&lt;br /&gt;            &lt;/span&gt;ViewState = statePair.First;&lt;br /&gt;            ControlState = statePair.Second;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Save the view state to persistent medium.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    /// &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;param name="viewState"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;View state to save.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public override void &lt;/span&gt;Save()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Create a pair for ViewState and ControlState&lt;br /&gt;        &lt;/span&gt;Pair statePair = &lt;span style="color: blue"&gt;new &lt;/span&gt;Pair(ViewState, ControlState);&lt;br /&gt;        IStateFormatter formatter = StateFormatter;&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Save the view state&lt;br /&gt;        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;id = GetViewStateID();&lt;br /&gt;        PageViewStateServices.Save(id, formatter.Serialize(statePair));&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: green"&gt;// Store the ID of the view state in a hidden form field&lt;br /&gt;        &lt;/span&gt;HtmlInputHidden control = _page.FindControl(&lt;span style="color: #a31515"&gt;"__VIEWSTATEID"&lt;/span&gt;) &lt;span style="color: blue"&gt;as &lt;/span&gt;HtmlInputHidden;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(control == &lt;span style="color: blue"&gt;null&lt;/span&gt;)&lt;br /&gt;        {&lt;br /&gt;            ScriptManager.RegisterHiddenField(_page, &lt;span style="color: #a31515"&gt;"__VIEWSTATEID"&lt;/span&gt;, id.ToString());&lt;br /&gt;        }&lt;br /&gt;        &lt;span style="color: blue"&gt;else&lt;br /&gt;        &lt;/span&gt;{&lt;br /&gt;            control.Value = id.ToString();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;pre class="code"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;strong&gt;SamplePageAdapter.cs&lt;/strong&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Data;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Configuration;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Security;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.WebControls;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;This class is the page adapter for the application.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;Created by Jason Hill on 26/6/2007.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-----------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SamplePageAdapter &lt;/span&gt;: System.Web.UI.Adapters.PageAdapter&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;-------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Gets the state persister for the page.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    ///     &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    ///     &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;-------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public override &lt;/span&gt;PageStatePersister GetStatePersister()&lt;br /&gt;    {&lt;br /&gt;        &lt;span style="color: blue"&gt;return new &lt;/span&gt;SamplePageStatePersister(Page);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&lt;strong&gt;App.Browser&lt;/strong&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;browsers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;browser &lt;/span&gt;&lt;span style="color: red"&gt;refID&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Default&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;controlAdapters&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;adapter &lt;/span&gt;&lt;span style="color: red"&gt;controlType&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;System.Web.UI.Page&lt;/span&gt;" &lt;span style="color: red"&gt;adapterType&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;SamplePageAdapter&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;controlAdapters&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;browser&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;browsers&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&lt;pre&gt;&lt;strong&gt;PageViewStateServices.cs&lt;/strong&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Data;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Data.SqlClient;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Collections;&lt;br /&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Text;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;--------------------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;This class provides services for handling page view state.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;br /&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;Created by Jason Hill on 26/6/2007.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;--------------------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;public static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PageViewStateServices&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;----------------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Get a page view state by ID.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    ///     &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    ///     &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;param name="id"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;ID.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;----------------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public static string &lt;/span&gt;GetByID(&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;id)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;SqlConnection &lt;/span&gt;connection = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt;(Common.PageViewStateConnectionString))&lt;br /&gt;        {&lt;br /&gt;            connection.Open();&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;try&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;SqlCommand &lt;/span&gt;command = connection.CreateCommand())&lt;br /&gt;                {&lt;br /&gt;                    command.CommandType = &lt;span style="color: #2b91af"&gt;CommandType&lt;/span&gt;.StoredProcedure;&lt;br /&gt;                    command.CommandText = &lt;span style="color: #a31515"&gt;"GetByID"&lt;/span&gt;;&lt;br /&gt;                    command.Parameters.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"@id"&lt;/span&gt;, id));&lt;br /&gt;                    &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;string&lt;/span&gt;)command.ExecuteScalar();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;finally&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                connection.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;Save the view state.&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;    /// &amp;lt;remarks&amp;gt;&lt;br /&gt;    ///     &amp;lt;author&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;jhill&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/author&amp;gt;&lt;br /&gt;    ///     &amp;lt;creation&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Wednesday, 30 May 2007&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/creation&amp;gt;&lt;br /&gt;    /// &amp;lt;/remarks&amp;gt;&lt;br /&gt;    /// &amp;lt;param name="id"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;Unique ID.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;    /// &amp;lt;param name="value"&amp;gt;&lt;/span&gt;&lt;span style="color: green"&gt;View state value.&lt;/span&gt;&lt;span style="color: gray"&gt;&amp;lt;/param&amp;gt;&lt;br /&gt;    /// &lt;/span&gt;&lt;span style="color: green"&gt;----------------------------------------------&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: blue"&gt;public static void &lt;/span&gt;Save(&lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;id, &lt;span style="color: blue"&gt;string &lt;/span&gt;value)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;SqlConnection &lt;/span&gt;connection = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt;(Common.PageViewStateConnectionString))&lt;br /&gt;        {&lt;br /&gt;            connection.Open();&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;try&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;&lt;br /&gt;                &lt;span style="color: blue"&gt;using &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;SqlCommand &lt;/span&gt;command = connection.CreateCommand())&lt;br /&gt;                {&lt;br /&gt;                    command.CommandType = &lt;span style="color: #2b91af"&gt;CommandType&lt;/span&gt;.StoredProcedure;&lt;br /&gt;                    command.CommandText = &lt;span style="color: #a31515"&gt;"SaveViewState"&lt;/span&gt;;&lt;br /&gt;                    command.Parameters.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"@id"&lt;/span&gt;, id));&lt;br /&gt;                    command.Parameters.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"@value"&lt;/span&gt;, value));&lt;br /&gt;                    command.ExecuteNonQuery();&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            &lt;span style="color: blue"&gt;finally&lt;br /&gt;            &lt;/span&gt;{&lt;br /&gt;                connection.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre&gt;&lt;pre&gt;&lt;pre&gt;&lt;strong&gt;PageViewState.sql&lt;/strong&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[PageViewState](&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    [ID] [uniqueidentifier] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    [&lt;span class="kwrd"&gt;Value&lt;/span&gt;] [text] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    [LastUpdatedOn] [datetime] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt; &lt;span class="kwrd"&gt;CONSTRAINT&lt;/span&gt; [PK_PageViewState] &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;(&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    [ID] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;)&lt;span class="kwrd"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  = &lt;span class="kwrd"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span class="kwrd"&gt;ON&lt;/span&gt;) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;] TEXTIMAGE_ON [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROCEDURE&lt;/span&gt; [dbo].[GetByID] &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    @id uniqueidentifier &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; NOCOUNT &lt;span class="kwrd"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;    &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;    &lt;span class="kwrd"&gt;select&lt;/span&gt; &lt;span class="kwrd"&gt;Value&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;    &lt;span class="kwrd"&gt;from&lt;/span&gt; PageViewState&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;    &lt;span class="kwrd"&gt;where&lt;/span&gt; ID = @id&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&lt;span class="kwrd"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; ANSI_NULLS &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;&lt;span class="kwrd"&gt;SET&lt;/span&gt; QUOTED_IDENTIFIER &lt;span class="kwrd"&gt;ON&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;PROCEDURE&lt;/span&gt; [dbo].[SaveViewState]&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;    @id uniqueidentifier, &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;    @&lt;span class="kwrd"&gt;value&lt;/span&gt; text&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;&lt;span class="kwrd"&gt;AS&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;    &lt;span class="kwrd"&gt;SET&lt;/span&gt; NOCOUNT &lt;span class="kwrd"&gt;ON&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;    &lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;exists&lt;/span&gt;(&lt;span class="kwrd"&gt;select&lt;/span&gt; ID &lt;span class="kwrd"&gt;from&lt;/span&gt; PageViewState &lt;span class="kwrd"&gt;where&lt;/span&gt; ID = @id))&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;        &lt;span class="kwrd"&gt;update&lt;/span&gt; PageViewState&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;        &lt;span class="kwrd"&gt;set&lt;/span&gt; &lt;span class="kwrd"&gt;Value&lt;/span&gt; = @&lt;span class="kwrd"&gt;value&lt;/span&gt;, LastUpdatedOn = getdate()&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;        &lt;span class="kwrd"&gt;where&lt;/span&gt; ID = @id&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;    &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;        insert &lt;span class="kwrd"&gt;into&lt;/span&gt; PageViewState&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;        (ID, &lt;span class="kwrd"&gt;Value&lt;/span&gt;, LastUpdatedOn)&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;        &lt;span class="kwrd"&gt;values&lt;/span&gt; (@id, @&lt;span class="kwrd"&gt;value&lt;/span&gt;, getdate())&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;&lt;span class="kwrd"&gt;END&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt; &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;pre&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/pre&gt;&lt;pre&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/pre&gt;&lt;pre&gt;&lt;strong&gt;CleanupPageViewState.sql&lt;/strong&gt;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;delete&lt;/span&gt; &lt;span class="kwrd"&gt;from&lt;/span&gt; PageViewState&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;where&lt;/span&gt; LastUpdatedOn &amp;lt; dateadd(&lt;span class="kwrd"&gt;minute&lt;/span&gt;, -240, &lt;span class="kwrd"&gt;current_timestamp&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://forums.asp.net/t/1293397.aspx" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-4347683015211839599?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/6uOFoCzfPbs" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4347683015211839599" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4347683015211839599" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/6uOFoCzfPbs/custom-persister-to-store-state-in.html" title="Custom Persister to store the state in a backend database" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/custom-persister-to-store-state-in.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-4835785070622976528</id><published>2009-08-10T23:04:00.001-07:00</published><updated>2009-08-10T23:04:15.746-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="vb.net" /><category scheme="http://www.blogger.com/atom/ns#" term="sample code" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="exe" /><category scheme="http://www.blogger.com/atom/ns#" term="Reflection" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="dll" /><title type="text">.NET: Getting the Path of the Executing Assembly</title><content type="html">&lt;p&gt;To retrieve the path of the executing assembly (the VB 6.0 equivalent of App.Path), use the following code:&lt;/p&gt;&lt;pre class="code"&gt;[C#]&lt;br /&gt;&lt;span style="color: #2b91af"&gt;String &lt;/span&gt;strPath = System.IO.&lt;span style="color: #2b91af"&gt;Path&lt;/span&gt;.GetDirectoryName(&lt;br /&gt; System.Reflection.&lt;span style="color: #2b91af"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().CodeBase);&lt;br /&gt;&lt;br /&gt;[Visual Basic]&lt;br /&gt;Dim strPath As String = System.IO.&lt;span style="color: #2b91af"&gt;Path&lt;/span&gt;.GetDirectoryName( _&lt;br /&gt; System.Reflection.&lt;span style="color: #2b91af"&gt;Assembly&lt;/span&gt;.GetExecutingAssembly().CodeBase)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://www.xoc.net/works/tips/path.asp" target="_blank"&gt;here&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/1002597578696693985-4835785070622976528?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/RF6ZmAUIqrg" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4835785070622976528" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4835785070622976528" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/RF6ZmAUIqrg/net-getting-path-of-executing-assembly.html" title=".NET: Getting the Path of the Executing Assembly" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/net-getting-path-of-executing-assembly.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-7823326402381226329</id><published>2009-08-10T23:01:00.001-07:00</published><updated>2009-08-10T23:05:02.565-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="vb.net" /><category scheme="http://www.blogger.com/atom/ns#" term="typeof" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="Reflection" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Attributes" /><title type="text">.NET: Retrieving Assembly Attributes</title><content type="html">&lt;p&gt;To retrieve the value set in the Assembly Attributes in the AssemblyInfo.cs or AssemblyInfo.vb file, use the code below. The example shows retrieving the AssemblyDescription attribute.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="code"&gt;[C#]&lt;br /&gt;&lt;span style="color: blue"&gt;private static readonly string &lt;/span&gt;strAssemblyDescription =&lt;br /&gt;    ((AssemblyDescriptionAttribute) &lt;br /&gt;    Assembly.GetExecutingAssembly().GetCustomAttributes(&lt;br /&gt;    &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(AssemblyDescriptionAttribute), &lt;span style="color: blue"&gt;false&lt;/span&gt;)[0]).Description;&lt;br /&gt;&lt;br /&gt;[Visual Basic]&lt;br /&gt;&lt;span style="color: blue"&gt;Private ReadOnly &lt;/span&gt;strAssemblyDescription As String = _&lt;br /&gt;    CType([Assembly].GetExecutingAssembly().GetCustomAttributes( _&lt;br /&gt;    GetT&lt;span style="color: blue"&gt;ype&lt;/span&gt;(AssemblyDescriptionAttribute), F&lt;span style="color: blue"&gt;alse&lt;/span&gt;), _&lt;br /&gt;    AssemblyDescriptionAttribute())(0).Description&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://www.xoc.net/works/tips/assembly-attributes.asp" target="_blank"&gt;here&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/1002597578696693985-7823326402381226329?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/vfcqaxNsVzc" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7823326402381226329" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7823326402381226329" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/vfcqaxNsVzc/net-retrieving-assembly-attributes.html" title=".NET: Retrieving Assembly Attributes" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/net-retrieving-assembly-attributes.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-5843882142863506369</id><published>2009-08-05T23:46:00.001-07:00</published><updated>2009-08-13T00:49:35.282-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title type="text">SQL SERVER – Get Time in Hour:Minute Format from a Datetime – Get Date Part Only from Datetime</title><content type="html">&lt;p&gt;I have seen scores of expert developers getting perplexed with SQL Server in finding time only from datetime datatype. Let us have a quick glance look at the solution.  &lt;p&gt;&lt;strong&gt;SQL Server 2000/2005&lt;/strong&gt; &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(8),GETDATE(),108) &lt;span class="kwrd"&gt;AS&lt;/span&gt; HourMinuteSecond,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;VARCHAR&lt;/span&gt;(8),GETDATE(),101) &lt;span class="kwrd"&gt;AS&lt;/span&gt; DateOnly&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;GO&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;img height="188" alt="" src="http://www.pinaldave.com/bimg/datetime2005.jpg" width="489"&gt; &lt;br /&gt;&lt;p&gt;&lt;strong&gt;SQL Server 2008&lt;/strong&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;TIME&lt;/span&gt;,GETDATE()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; HourMinuteSecond,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;CONVERT&lt;/span&gt;(&lt;span class="kwrd"&gt;DATE&lt;/span&gt;,GETDATE(),101) &lt;span class="kwrd"&gt;AS&lt;/span&gt; DateOnly&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;GO&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;img height="184" alt="" src="http://www.pinaldave.com/bimg/datetime2008.jpg" width="413"&gt; &lt;br /&gt;&lt;p&gt;I hope the above solution is clear to you all. &lt;br /&gt;&lt;p&gt;Reference : &lt;strong&gt;Pinal Dave (&lt;a href="http://blog.sqlauthority.com/"&gt;http://blog.SQLAuthority.com&lt;/a&gt;)&lt;/strong&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-5843882142863506369?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/Vfw2M_5H35Q" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5843882142863506369" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5843882142863506369" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/Vfw2M_5H35Q/sql-server-get-time-in-hourminute.html" title="SQL SERVER – Get Time in Hour:Minute Format from a Datetime – Get Date Part Only from Datetime" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/08/sql-server-get-time-in-hourminute.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-2281824742538294048</id><published>2009-07-30T06:20:00.001-07:00</published><updated>2009-08-13T00:52:53.635-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="sample code" /><category scheme="http://www.blogger.com/atom/ns#" term="Open Source" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="JAVASCRIPT" /><category scheme="http://www.blogger.com/atom/ns#" term="google" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title type="text">Setting up Visual Studio Intellisense for jQuery</title><content type="html">&lt;h4&gt;by &lt;a href="http://www.learningjquery.com/2009/07/setting-up-visual-studio-intellisense-for-jquery"&gt;Ralph Whitbeck&lt;/a&gt;&lt;/h4&gt; &lt;p&gt;In September 2008, at the jQuery Conference, it was announced that Microsoft would be shipping its upcoming releases of Visual Studio with jQuery built in. They would not fork or change the jQuery code but ship it as is. Microsoft also announced that they would distribute IntelliSense-annotated documentation JavaScript files for Visual Studio 2008 that developers can reference in their files to enable IntelliSense for jQuery. The following instructions will help you get started using this tool to make writing jQuery scripts faster than ever.  &lt;h6&gt;Setting up Your Files for jQuery IntelliSense&lt;/h6&gt; &lt;p&gt;First, set up jQuery on your page by downloading the latest version from the &lt;a href="http://docs.jquery.com/Downloading_jQuery"&gt;jQuery site&lt;/a&gt;.  &lt;p&gt;Next, you will need to download the &lt;a href="http://docs.jquery.com/Downloading_jQuery"&gt;jQuery Documentation file from the jQuery site&lt;/a&gt;.  &lt;p&gt;&lt;img height="132" alt="download documentation" src="http://www.learningjquery.com/wp-content/uploads/vs-download.png" width="379"&gt;  &lt;p&gt;Download the files and add them to your project.  &lt;h6&gt;IntelliSense in external JavaScript files&lt;/h6&gt; &lt;p&gt;At the top of the JavaScript file in which you would like to have jQuery IntelliSense enabled, you will need to add a line to reference the documentation file:&lt;pre&gt;&lt;code&gt;&lt;strong&gt;/// &amp;lt;reference path="jquery-1.3.2-vsdoc2.js" /&amp;gt;&lt;/strong&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h6&gt;IntelliSense inline on your ASPX page&lt;/h6&gt;&lt;br /&gt;&lt;p&gt;There are a couple of scenarios that may affect if you include a reference to the VSDOC file or not. If in doubt, just add a reference to the documentation file. &lt;br /&gt;&lt;p&gt;If you are linking to jQuery by the &lt;a href="http://code.google.com/apis/ajaxlibs/"&gt;Google Code AJAX Library&lt;/a&gt; or are linking to jQuery from anywhere outside of your project you will need to reference the documentation file. &lt;br /&gt;&lt;p&gt;From each ASPX page you want jQuery IntelliSense you’ll want to call the reference within a server-side conditional statement so that the documentation file will still load in Visual Studio but will not load at run-time. Add the following after your jQuery declaration: &lt;br /&gt;&lt;p&gt;&lt;a href="http://www.learningjquery.com/2009/07/setting-up-visual-studio-intellisense-for-jquery#"&gt;PLAIN TEXT&lt;/a&gt; &lt;br /&gt;&lt;p&gt;ASP: &lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&amp;lt;script src=&lt;span class="str"&gt;"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;lt;% &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;false&lt;/span&gt;) { %&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  &amp;lt;script type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt; src=&lt;span class="str"&gt;"jquery-1.3.2-vsdoc2.js"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&amp;lt;% } %&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you downloaded jQuery and saved it to your project Visual Studio will look for the vsdoc.js file automatically if the following conditions are met. &lt;br /&gt;&lt;p&gt;You've downloaded and installed the &lt;a href="http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx"&gt;hotfix&lt;/a&gt; for Visual Studio. &lt;br /&gt;&lt;p&gt;jQuery and the documentation file need to be named the same with the exception that the documentation file end with -vsdoc.js. So when you add jQuery to your project make sure to rename them similarly. For instance, &lt;strong&gt;jquery-1.3.2&lt;/strong&gt;.js is your jQuery library, Visual Studio will look for the documentation file at &lt;strong&gt;jquery-1.3.2&lt;/strong&gt;-vsdoc.js and load it. &lt;br /&gt;&lt;p&gt;(Note: the jQuery 1.3.2 documentation file is named jquery-1.3.2-vsdoc2.js on the Download page so make sure you take out the 2 so that the file will be found by Visual Studio) &lt;br /&gt;&lt;p&gt;If you can't meet these conditions you'll need to reference the documentation file as shown above. &lt;br /&gt;&lt;p&gt;To test to make sure the documentation file loaded correctly, you can type &lt;code&gt;$(&lt;/code&gt; and you should be presented with some documentation. &lt;br /&gt;&lt;p&gt;&lt;img height="96" alt="test IntelliSense" src="http://www.learningjquery.com/wp-content/uploads/vs-test.png" width="576"&gt; &lt;br /&gt;&lt;p&gt;Additionally, you can type in &lt;code&gt;$(document).r&lt;/code&gt; and you will be presented with a drop down of available options to choose from, one being "ready." &lt;br /&gt;&lt;p&gt;&lt;img height="169" alt="test with document ready" src="http://www.learningjquery.com/wp-content/uploads/vs-docready.png" width="541"&gt; &lt;br /&gt;&lt;p&gt;Now as you write your jQuery code, you'll be helped along by seeing what methods and properties are available to you. &lt;br /&gt;&lt;h6&gt;Related Links&lt;/h6&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-IntelliSense-for-jquery.aspx"&gt;Rich IntelliSense for jQuery&lt;/a&gt; &lt;br /&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx"&gt;jQuery and Microsoft&lt;/a&gt; &lt;br /&gt;&lt;li&gt;&lt;a href="http://blog.jquery.com/2008/09/28/jquery-microsoft-nokia/"&gt;jQuery, Microsoft and Nokia&lt;/a&gt; &lt;br /&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx"&gt;VS2008 SP1 Hotfix to Support "-vsdoc.js" IntelliSense Doc Files&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h6&gt;Update&lt;/h6&gt;&lt;br /&gt;&lt;p&gt;I've updated the post to reflect the hotfix for Visual Studio which enables Visual Studio to automatically load the documentation file for inline jQuery on ASPX pages if it's named similarly to the jQuery file. Thanks to Dave Ward for pointing this out in the comments. &lt;br /&gt;&lt;p&gt;&lt;a href="http://www.learningjquery.com/scripts-used-on-this-site"&gt;Scripts Used on This Site&lt;/a&gt; &lt;br /&gt;&lt;p&gt;&amp;nbsp; &lt;p&gt;Original post can be found &lt;a href="http://www.learningjquery.com/2009/07/setting-up-visual-studio-intellisense-for-jquery" target="_blank"&gt;here...&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/1002597578696693985-2281824742538294048?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/uu10p26DMMo" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2281824742538294048" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2281824742538294048" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/uu10p26DMMo/setting-up-visual-studio-intellisense.html" title="Setting up Visual Studio Intellisense for jQuery" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/setting-up-visual-studio-intellisense.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-1839709554013127257</id><published>2009-07-29T22:12:00.000-07:00</published><updated>2009-07-28T22:15:50.416-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Web Content Accessibility Guidlines" /><title type="text">Web Content Accessibility Guidelines (WCAG) 2.0</title><content type="html">&lt;h4&gt;Abstract&lt;/h4&gt; &lt;p&gt;Web Content Accessibility Guidelines (WCAG) 2.0 covers a wide range of recommendations for making Web content more accessible. Following these guidelines will make content accessible to a wider range of people with disabilities, including blindness and low vision, deafness and hearing loss, learning disabilities, cognitive limitations, limited movement, speech disabilities, photosensitivity and combinations of these. Following these guidelines will also often make your Web content more usable to users in general.  &lt;p&gt;WCAG 2.0 success criteria are written as testable statements that are not technology-specific. Guidance about satisfying the success criteria in specific technologies, as well as general information about interpreting the success criteria, is provided in separate documents. See &lt;a href="http://www.w3.org/WAI/intro/wcag.php"&gt;Web Content Accessibility Guidelines (WCAG) Overview&lt;/a&gt; for an introduction and links to WCAG technical and educational material.  &lt;p&gt;WCAG 2.0 succeeds &lt;a href="http://www.w3.org/TR/WCAG10/"&gt;Web Content Accessibility Guidelines 1.0&lt;/a&gt; &lt;a href="http://www.w3.org/TR/WCAG20/#WCAG10"&gt;[WCAG10]&lt;/a&gt;, which was published as a W3C Recommendation May 1999. Although it is possible to conform either to WCAG 1.0 or to WCAG 2.0 (or both), the W3C recommends that new and updated content use WCAG 2.0. The W3C also recommends that Web accessibility policies reference WCAG 2.0.  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;read &lt;a href="http://www.w3.org/TR/WCAG20/" target="_blank"&gt;more...&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/1002597578696693985-1839709554013127257?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/X0B1YW_zRIQ" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1839709554013127257" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1839709554013127257" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/X0B1YW_zRIQ/web-content-accessibility-guidelines.html" title="Web Content Accessibility Guidelines (WCAG) 2.0" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/web-content-accessibility-guidelines.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-1139374806480679710</id><published>2009-07-28T21:54:00.000-07:00</published><updated>2009-07-28T21:55:48.002-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="framework" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="CSLA .NET" /><category scheme="http://www.blogger.com/atom/ns#" term="CODESMITH" /><title type="text">What is CSLA .NET?</title><content type="html">&lt;p&gt;&lt;img src="http://www.lhotka.net/images/csla_logo1_72.png" border="0"&gt; &lt;p&gt;&lt;a href="http://www.lhotka.net/cslanet"&gt;CSLA .NET&lt;/a&gt; is a software development framework that helps you build a powerful, maintainable business logic layer for Windows, Web, service-oriented and workflow applications.  &lt;p&gt;There are many frameworks in the world. Most of them focus on the common issues of getting data into and out of the database or creating a flexible UI. What is typically missing is a focus on managing or implementing business logic. This puzzles me, because business logic is the centerpiece of a business application. &lt;p&gt;Helping to manage and implement this business logic is the purpose of my CSLA .NET framework and is the focus of my &lt;em&gt;Expert Business Objects &lt;/em&gt;books. &lt;p&gt;CSLA .NET enables you to create an object-oriented business layer that abstracts and encapsulates your business logic and data. The framework ensures your business objects fully support data binding in WPF, Silverlight, ASP.NET Web Forms and Windows Forms. It also supports ASP.NET MVC, Windows Workflow Foundation, WCF and web services interfaces. &lt;p&gt;CSLA .NET simplifies and standarizes implementation of business logic, validation and authorization logic within your objects. The goal is to provide an easy and consistent coding pattern by which you can encapsulate all your business logic within your object-oriented business layer. The result is a business layer that can support all the interface types listed above, while remaining decoupled from any specific interface technology. &lt;p&gt;CSLA .NET includes a technology-neutral client/server abstraction, allowing you to build your application and then decide at deployment whether to use 2-tier or 3-tier client/server (and 4-tier with Silverlight). If you opt for 3-tier deployment, you can choose between WCF, .NET Remoting, Web Services or Enterprise Services as a network protocol. The key point here is that you can switch between 2-tier and any of these 3-tier networking options without changing your UI, business logic or data access code; all that changes is a configuration file (and of course deployment to both client and server). &lt;p&gt;Finally, CSLA .NET provides a clearly defined location in your architecture where you get data from or put data into the database. This is not the focus of CSLA .NET, and so the framework’s goal is to put you in charge. To give &lt;em&gt;you&lt;/em&gt; optimum flexibility in how that data is managed and to enable decoupling of the data access from the business object and user interface or presentation layers. &lt;p&gt;CSLA stands for Component-based, Scalable Logical Architecture, and is the result of over 12 years worth of research and development. The .NET implementation of CSLA was started in 1999, and development continues today, with the addition of &lt;a href="http://www.lhotka.net/cslalight/info.aspx"&gt;CSLA .NET for Silverlight&lt;/a&gt; and upcoming support for Silverlight 3.0 and Microsoft .NET 4.0. &lt;p&gt;(Updated 5/20/2009) &lt;p&gt;Original article can be found &lt;a href="http://www.lhotka.net/cslanet/Info.aspx" target="_blank"&gt;here&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/1002597578696693985-1139374806480679710?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/wQJ4fxDyLoo" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1139374806480679710" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1139374806480679710" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/wQJ4fxDyLoo/what-is-csla-net.html" title="What is CSLA .NET?" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/what-is-csla-net.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-2706092942966277475</id><published>2009-07-27T02:51:00.001-07:00</published><updated>2009-07-27T02:51:52.617-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Open Source" /><category scheme="http://www.blogger.com/atom/ns#" term="LINUX" /><title type="text">What makes a good Linux distribution?</title><content type="html">&lt;h4&gt;&amp;nbsp;&lt;/h4&gt; &lt;p&gt;By Jack Wallen, Special to ZDNet Asia&lt;br&gt;Monday, July 27, 2009 12:38 PM &lt;p&gt;&lt;a href="http://www.techrepublic.com"&gt;&lt;img src="http://www.asia.cnet.com/i/it/2002/ITManager_2004/images/techrepublic.jpg" align="right" border="0"&gt;&lt;/a&gt; &lt;strong&gt;Take the proprietary driver system and installation tools of Ubuntu, add the desktop of Elive+Compiz, add the foundation of Debian, and the security of Bastille Linux and you would have one killer distribution.&lt;/strong&gt; &lt;p&gt;Lately, I have written various articles that have stirred the pot regarding the various Linux distributions available. I have heard quite a bit of dislike for Ubuntu, GNOME, and KDE 4. In fact I have heard opinions from people that make me wonder why they even use Linux. &lt;p&gt;I have come across plenty of distributions that I will never use again. I have played with desktops that will only have ever graced my screen once or twice. But to say I hate them? No matter how much I dislike these tools, they are still a part of the Linux community and that at least gives them some credibility. &lt;p&gt;But this train of thought started my brain whirring around the idea of "what makes a good Linux distribution?" I thought, what better place to ask this question than here at Techrepublic! Naturally I can't just ask the question without offering up my own opinion on the subject as well. &lt;p&gt;&lt;b&gt;Standards&lt;/b&gt;&lt;br&gt;I would have liked to think by now all Linux distributions would be following some semblance of standards. I don't find this to be the truth. And why? There';s an organization built around creating standards for Linux. The Linux Standards Base was created to try to set standards for which all distributions could follow. So far this has not paid off. I can understand the struggle, but how hard could it be to set smart guidelines and, if a distribution follows those guidelines, give them some seal of approval. &lt;p&gt;The Linux community has to understand if standards are set and followed, developement (and acceptance) for the operating system will be that much easier. &lt;p&gt;&lt;b&gt;Drivers&lt;/b&gt;&lt;br&gt;In order for a distribution to be successful it has to include drivers for hardware to work. Yes this might mean that non-free drivers must be included. But that is a small price to pay for a Linux installation to work. The less distributions work out of the box, the less acceptance and use they will see. This is where the Ubuntu distribution shines. Adding proprietary drivers so that NVidia card will use the correct resolution, or that wireless card will work is simple. More distributions should follow this example. &lt;p&gt;&lt;b&gt;Desktops&lt;/b&gt;&lt;br&gt;It is clear there are camps for every desktop available to the Linux operating system. And these camps are very vocal in their dislike of the other. GNOME hates KDE hates GNOME hates Enlightenment hates Fluxbox, etc. And it only makes sense that a distribution make a choice for a default. But that doesn't mean the distribution can not offer the other desktops to the user. This should be the case during installation--even with Live CDs. &lt;p&gt;The installation should ask the user if they want extra desktops installed, or a different desktop installed. Or if that's not the answer - then the installation of said desktops should be made simple with the help of tools like Synaptic. There should be a single check box to install the whole of KDE or GNOME or Enlightenment. Make it easy people! Give the users choice. &lt;p&gt;Remember the old days of Linux installation where you were asked which desktop you wanted to install? Bring that back. And standards should be followed. A KDE desktop should fundamentally look and feel like any other KDE desktop so users have a better chance of getting used to the Linux desktop. &lt;p&gt;&lt;b&gt;Help system&lt;/b&gt;&lt;br&gt;For many users that are familiar with Linux, this really isn't an issue. But for new users a good help system is critical. Most help systems included with a distribution generally focus only on the desktop. Add to this some fundamental Linux help and you have a winner. &lt;p&gt;&lt;b&gt;Make it all work&lt;/b&gt;&lt;br&gt;One of the reasons why the average user doesn't really think twice about their operating system is because when they fire up that PC for the first time everything just works. They don';t have to install a flash plugin or Java or a library so their iPod will connect or they can listen to MP3s. These should all be automatic on every distribution. Period. And the MP3 licensing issue - that needs to seriously go away. People use MP3s. How many times have you had to help someone roll MP3 support into Rhythmbox, Banshee, or XMMS? &lt;p&gt;&lt;b&gt;Security&lt;/b&gt;&lt;br&gt;Most distributions have this inherent in their systems and subsystems. This could easily fall in line with standards. You have some distributions using SELinux and some not. You have some distributions adding a GUI firewall tool by default and some not. I am not the biggest fan of SELinux only because when it works its best, it can get in the way of applications running (have you had SELinux stop acroread from starting up?). I think the desktop standard should simply be iptables with policies set so that nothing can get in and normal services can get out. &lt;p&gt;&lt;b&gt;Eye Candy&lt;/b&gt;&lt;br&gt;Let's face it--if you';ve got it, flaunt it. With the help of Compiz, Linux can have the most amazing desktop among all of the operating systems. But in most Compiz-enabled distribution installations I have seen, they have visual effects set to Normal. This leaves out the Compiz Cube, wobbly windows, and a number of other mind-blowing features. &lt;p&gt;If a machine's hardware can handle it, the default needs to be Extra or Custom. Out of the box (again, if the hardware supports it), all of the Compiz goodness should work. And the key combinations need to be standardized (there it is again!). &lt;p&gt;&lt;b&gt;Final thoughts&lt;/b&gt;&lt;br&gt;Where do you stand? In your opinion, what makes a good Linux distribution? If you could roll in various aspects of any distro together what would your final results look like? Here';s what I would do: &lt;p&gt;Take the proprietary driver system and installation tools of Ubuntu, add the desktop of Elive+Compiz, add the foundation of Debian, and the security of Bastille Linux and you would have one killer distribution! Your turn. &lt;p&gt;&lt;i&gt;Jack Wallen was a key player in the introduction of Linux to the original Techrepublic. Beginning with Red Hat 4.2 and a mighty soap box, Jack had found his escape from Windows. It was around Red Hat 6.0 that Jack landed in the hallowed halls of Techrepublic. &lt;/i&gt; &lt;p&gt;&lt;em&gt;&lt;/em&gt;&amp;nbsp; &lt;p&gt;&lt;em&gt;Original post can be found &lt;a href="http://www.zdnetasia.com/techguide/opensource/0,39044899,62056363,00.htm?scid=nl_z_tgos#talkback" target="_blank"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-2706092942966277475?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/EnLcws1eizI" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2706092942966277475" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2706092942966277475" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/EnLcws1eizI/what-makes-good-linux-distribution.html" title="What makes a good Linux distribution?" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/what-makes-good-linux-distribution.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-5825078295171590424</id><published>2009-07-22T22:53:00.001-07:00</published><updated>2009-08-13T00:55:05.708-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="AJAX" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="JAVASCRIPT" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title type="text">Simplify calling ASP.NET AJAX services from jQuery</title><content type="html">&lt;h4&gt;&lt;a href="http://encosia.com/category/ajax/"&gt;AJAX&lt;/a&gt;, &lt;a href="http://encosia.com/category/aspnet/"&gt;ASP.NET&lt;/a&gt;, &lt;a href="http://encosia.com/category/javascript/"&gt;JavaScript&lt;/a&gt;, &lt;a href="http://encosia.com/category/jquery/"&gt;jQuery&lt;/a&gt; By &lt;strong&gt;Dave Ward&lt;/strong&gt; on July 21st, 2009&lt;/h4&gt; &lt;p&gt;As jQuery’s popularity in the .NET community has risen over the past year, one recurring theme I’ve seen is the desire to refactor away the details of using it to call ASP.NET AJAX services. Whether through helper function or specialized jQuery plugin, I’ve seen numerous methods proposed and/or in use.  &lt;p&gt;Personally, the syntax never bothered me. The contentType parameter is ugly, but I have a Visual Studio code snippet for the $.ajax call and rarely think about it.  &lt;p&gt;That came to an end earlier this year, when I started using dataFilter. I needed to &lt;a href="http://encosia.com/2009/06/29/never-worry-about-asp-net-ajaxs-d-again/"&gt;isolate my code from the “.d” issue&lt;/a&gt;, and wanted to &lt;a href="http://encosia.com/2009/07/07/improving-jquery-json-performance-and-security/"&gt;take advantage of browser-native JSON parsing&lt;/a&gt; in Firefox 3.5 and IE8, which required a bulky dataFilter.  &lt;p&gt;Repeating that entire callback function in every $.ajax call was not acceptable. So, I was happy to learn that jQuery provides an excellent solution for consolidating settings to be used in multiple instances of $.ajax.  &lt;p&gt;In this post, I’ll show you &lt;strong&gt;how to use that consolidation feature&lt;/strong&gt;, and exactly how I am now using that to &lt;strong&gt;more simply call ASP.NET AJAX services with jQuery&lt;/strong&gt;.  &lt;h5&gt;Configuring $.ajax’s default settings&lt;/h5&gt; &lt;p&gt;Rather than wrapping the $.ajax call in a plugin or helper function, jQuery provides a built-in solution that I think is a better alternative:&amp;nbsp; &lt;a href="http://docs.jquery.com/Ajax/jQuery.ajaxSetup"&gt;$.ajaxSetup&lt;/a&gt;.  &lt;p&gt;$.ajaxSetup accepts an array of settings that allows you to supply defaults for any of the parameters that you would set in an $.ajax call. Settings like &lt;strong&gt;contentType&lt;/strong&gt;, &lt;strong&gt;type&lt;/strong&gt;, and &lt;strong&gt;dataFilter&lt;/strong&gt; are all fair game, for example.  &lt;p&gt;Using this function, it’s easy to set jQuery’s $.ajax defaults to match &lt;a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/"&gt;the refined settings that we worked out together last year&lt;/a&gt;: &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;$.ajaxSetup({&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;  type: &lt;span class="str"&gt;"POST"&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;  contentType: &lt;span class="str"&gt;"application/json; charset=utf-8"&lt;/span&gt;,&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;  data: &lt;span class="str"&gt;"{}"&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Because &lt;strong&gt;parameters to&lt;/strong&gt; &lt;strong&gt;$.ajax override these defaults&lt;/strong&gt;, presetting “data” to an empty JSON string is safe. Any $.ajax call that does specify a data parameter will function as expected, since the default will be ignored. &lt;br /&gt;&lt;p&gt;The particular issue caused by forgetting the empty data parameter can be difficult to track down, and only shows up after you’ve deployed your application to IIS. So, having the default as a safety net is recommended. &lt;br /&gt;&lt;h5&gt;Adding JSON parsing improvements&lt;/h5&gt;&lt;br /&gt;&lt;p&gt;Because $.ajaxSetup also supports setting a dataFilter, adding &lt;a href="http://encosia.com/2009/06/29/never-worry-about-asp-net-ajaxs-d-again/"&gt;the “.d” isolation&lt;/a&gt; and &lt;a href="http://encosia.com/2009/07/07/improving-jquery-json-performance-and-security/"&gt;browser-native JSON parsing&lt;/a&gt; from my last two posts is easy:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;$.ajaxSetup({&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;  type: "POST",&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;  contentType: "application/json; charset=utf-8",&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;  data: "{}",&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  dataFilter: function(data) {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    var msg;   if (typeof (JSON) !== 'undefined' &amp;amp;&amp;amp; &lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        typeof (JSON.parse) === 'function')&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;      msg = JSON.parse(data);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    else&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;      msg = eval('(' + data + ')');   if (msg.hasOwnProperty('d'))&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;      return msg.d;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    else&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;      return msg;&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;  }&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This dataFilter processing is actually what pushed me to start using $.ajaxSetup in all of my own projects. It was one thing to accept multiple contentType and method declarations, but repeating the dataFilter for every $.ajax call was more than I could handle. &lt;br /&gt;&lt;h5&gt;Putting it to work&lt;/h5&gt;&lt;br /&gt;&lt;p&gt;With the ASP.NET AJAX defaults set in $.ajaxSetup, &lt;strong&gt;all that’s required to call a “ScriptService” or page method is the URL and a success callback&lt;/strong&gt;:&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;$.ajax({&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;  url: &lt;span class="str"&gt;"HelloWorld.asmx/Hello"&lt;/span&gt;,&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;  success: &lt;span class="kwrd"&gt;function&lt;/span&gt;(msg) {&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    console.log(msg);&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;  }&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;});&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In fact, even the success callback is optional. For example, if you were periodically pinging a “heartbeat” service to keep the user’s session alive, $.ajax would only need the service’s URI. &lt;br /&gt;&lt;p&gt;This more concise syntax makes your service calls &lt;em&gt;far&lt;/em&gt; more readable, especially for developers who aren’t familiar with the content-type required by ASP.NET AJAX. &lt;br /&gt;&lt;h5&gt;Caution: Sometimes it works too well&lt;/h5&gt;&lt;br /&gt;&lt;p&gt;While this is a handy way to simplify calls to ASP.NET AJAX services, do understand that &lt;strong&gt;$.ajaxSetup applies to all of jQuery’s AJAX derivatives&lt;/strong&gt;. Setting the default HTTP method and content-type may also impact code and plugins that use jQuery’s built-in communication functionality (e.g. $.getJSON, $.post, etc). &lt;br /&gt;&lt;p&gt;For example, I often &lt;a href="http://encosia.com/2008/06/26/use-jquery-and-aspnet-ajax-to-build-a-client-side-repeater/"&gt;use jTemplates as a client-side templating solution&lt;/a&gt;. Because its processTemplateURL routine relies on $.ajax to retrieve remote template files, setting the ASP.NET AJAX content-type and POST method in $.ajaxSetup breaks that functionality of jTemplates. &lt;br /&gt;&lt;p&gt;Fixing that problem wasn’t difficult, but it also wasn’t immediately obvious what had caused the issue in the first place. In my experience using this technique, the undesirable side effects are rare enough that it’s not a serious concern, but do be aware of the potential. &lt;br /&gt;&lt;h5&gt;Conclusion&lt;/h5&gt;&lt;br /&gt;&lt;p&gt;I’ve been using this in production for several months now, with great results. Users have noticed the increased speed that came with browser-native JSON parsing, the “.d” isolation has reduced regression errors due to some code we run on both 2.0 and 3.5 servers, and &lt;strong&gt;it requires less effort on my part to do all that&lt;/strong&gt;. &lt;br /&gt;&lt;p&gt;What do you think? Is this helpful? &lt;br /&gt;&lt;p&gt;Would a Visual Studio template with this rolled in be something you would use? &lt;br /&gt;&lt;p&gt;&amp;nbsp; &lt;p&gt;Original post can be found &lt;a href="http://encosia.com/2009/07/21/simplify-calling-asp-net-ajax-services-from-jquery/" target="_blank"&gt;here&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/1002597578696693985-5825078295171590424?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/Qyvl1oXsQxg" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5825078295171590424" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5825078295171590424" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/Qyvl1oXsQxg/simplify-calling-aspnet-ajax-services.html" title="Simplify calling ASP.NET AJAX services from jQuery" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/simplify-calling-aspnet-ajax-services.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-2440029098904872062</id><published>2009-07-21T03:26:00.001-07:00</published><updated>2009-07-21T03:26:43.579-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PROGRAMMING" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL" /><title type="text">Nested LEFT JOINs to link three or more tables</title><content type="html">&lt;h4&gt;Posted on Monday 2005.08.15 at 7:38 pm in &lt;a href="http://arcanius.silverfir.net/blog/category/everything"&gt;Everything&lt;/a&gt;, &lt;a href="http://arcanius.silverfir.net/blog/category/everything/technology"&gt;Technology&lt;/a&gt;&lt;/h4&gt; &lt;p&gt;By Ryan McElroy  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This post is over 3 years old. It may contain outdated information and broken links. Please temper your expectations accordingly. &lt;p&gt;I ran into another dilemma in SQL-land today. Working on a money-management application, I had three tables that I wanted to gather information from. This normally leads to some relatively straightforward SQL:&lt;br&gt;&lt;code&gt;&lt;br&gt;SELECT account.name, contact.name, date, amount, type&lt;br&gt;FROM transactions, accounts, contacts&lt;br&gt;WHERE account_id = accounts.id&lt;br&gt;AND contact_id = contacts.id;&lt;br&gt;&lt;/code&gt;&lt;br&gt;However, this returned results only for transactions that had both matching accounts and matching contacts, while what I wanted was a single record for each transaction, regardless of matching accounts or contacts. For two tables, this would be straightforward with a LEFT JOIN:&lt;br&gt;&lt;code&gt;&lt;br&gt;SELECT account.name, date, amount, type&lt;br&gt;FROM transactions LEFT JOIN accounts&lt;br&gt;ON account_id = accounts.id;&lt;br&gt;&lt;/code&gt;&lt;br&gt;Which would return a row for every entry in the transactions table even if no matching account was found. I tried extrapolating that two three tables, like this:&lt;br&gt;&lt;code&gt;&lt;br&gt;SELECT account.name, contact.name, date, amount, type&lt;br&gt;FROM FROM transactions LEFT JOIN accounts, contacts&lt;br&gt;WHERE account_id = accounts.id&lt;br&gt;AND contact_id = contacts.id;&lt;br&gt;&lt;/code&gt;&lt;br&gt;However, this didn’t do what I wanted, and I was getting multiple entries for each transaction. So I googled for help, and Google delivered: &lt;a href="http://www.wellho.net/solutions/mysql-left-joins-to-link-three-or-more-tables.html"&gt;Left Joins to link three or more tables&lt;/a&gt;. From the information in this article, I was able to develop the SQL code that did exactly what I wanted:&lt;br&gt;&lt;code&gt;&lt;br&gt;SELECT `accounts`.`name` AS account_name,&lt;br&gt;`contacts`.`name` AS contact_name,&lt;br&gt;`date`, `amount`, `type`, `detail`, `memo`, `cleared`&lt;br&gt;FROM (`transactions` LEFT JOIN `accounts` ON `accounts`.`id` = `account_id`)&lt;br&gt;LEFT JOIN `contacts` ON `contacts`.`id` = `contact_id`&lt;br&gt;WHERE `parent_id` = 0&lt;br&gt;&lt;/code&gt;&lt;br&gt;This returns a single row for each entry in transactions, even if matching accounts and contacts are not found. Esentially, it is a nested LEFT JOIN. First, MySQL left joins transactions and accounts, then it takes this result and similarly left joins contacts. This way, every row in the leftmost table (transactions) is preserved. I might have simply linked to the site, but I didn’t like the naming scheme in the examples on that site (crypic names like bdg and dom don’t earn accolades from me), and I came up with a better article title, “Nested”.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-2440029098904872062?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/AvVkilfN7l8" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2440029098904872062" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/2440029098904872062" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/AvVkilfN7l8/nested-left-joins-to-link-three-or-more.html" title="Nested LEFT JOINs to link three or more tables" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/nested-left-joins-to-link-three-or-more.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-7367824465872836304</id><published>2009-07-16T03:04:00.001-07:00</published><updated>2009-07-16T03:04:23.430-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="WordPress Themes" /><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><title type="text">How To Create WordPress Themes From Scratch Part 1</title><content type="html">&lt;h4&gt;&lt;small&gt;July 14th, 2008 by &lt;a href="http://themetation.com/author/kailoon/"&gt;kailoon&lt;/a&gt; under &lt;a href="http://themetation.com/category/blog/tips/"&gt;Tips&lt;/a&gt;&lt;/small&gt;&lt;/h4&gt; &lt;p&gt;&lt;img src="http://themetation.com/smallthumb/tips.png"&gt; &lt;p&gt;I’m going to show you how to create a wordpress theme from scratch in these 3 parts of tutorial series. I will cover from Structuring, designing in Photoshop, slicing, coding into fully css based html, and finally wordpress implementation. &lt;h5&gt;Table Of Content&lt;/h5&gt; &lt;p&gt;Below is the index of the topics that we will go through: &lt;ol&gt; &lt;li&gt;Structuring, Designing in Photoshop.  &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-2/"&gt;Slicing and Coding&lt;/a&gt;.  &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a/"&gt;WordPress Implementation&lt;/a&gt;.  &lt;ol&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#1"&gt;header.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#2"&gt;sidebar.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#3"&gt;about.php&lt;/a&gt; – a custom file for the about section in the sidebar.  &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#4"&gt;footer.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#5"&gt;index.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3a#6"&gt;featured-post.php&lt;/a&gt; – a custom file for the featured posts.  &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#7"&gt;page.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#8"&gt;single.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#9"&gt;comments.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#10"&gt;archives.php, links.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#11"&gt;search.php, searchform.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#12"&gt;function.php&lt;/a&gt; &lt;li&gt;&lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-3b#13"&gt;image.php&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ol&gt; &lt;h5&gt;Structuring&lt;/h5&gt; &lt;p&gt;This is a very important part in designing a web layout. We need to structure our layout before open Photoshop. The first thing is the purpose of the layout. In our case, this will be a blog layout for WordPress. So, below is what we have in a blog: &lt;ol&gt; &lt;li&gt;Header  &lt;li&gt;Posting area  &lt;li&gt;Sidebar  &lt;li&gt;Single page  &lt;li&gt;Comment  &lt;li&gt;Feedback  &lt;li&gt;Searching field  &lt;li&gt;Page menu  &lt;li&gt;RSS  &lt;li&gt;Archives, Links and About Page &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Something we need to keep in mind. We can’t put all things into one basket. So, we CANNOT: &lt;ol&gt; &lt;li&gt;Display too many things in one single page.  &lt;li&gt;Use too many colors and font type. &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;In this sample, I also try to make is as simple as possible because the purpose of this series of tutorial is to give an example on how to create a wordpress theme. I am going to have a featured post section on the main page. Below is the Final image that we will create. &lt;h6&gt;Final Result&lt;/h6&gt; &lt;p&gt;&lt;a href="http://themetation.com/img/how1/large.jpg"&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/final.jpg"&gt;&lt;/a&gt; &lt;h5&gt;Photoshop&lt;/h5&gt; &lt;h6&gt;Step 1&lt;/h6&gt; &lt;p&gt;Create a new document with &lt;strong&gt;1024px X 768px&lt;/strong&gt; as we are going to create a layout which suit for &lt;strong&gt;1024px resolution&lt;/strong&gt;. Fill it the background layer with &lt;strong&gt;#eae8c6&lt;/strong&gt;. Now, &lt;strong&gt;CTRL + R&lt;/strong&gt; to bring out the ruler. Draw some guide line for the divine proportion we need. Before this, make sure it is snap. Go to &lt;strong&gt;View&lt;/strong&gt; &amp;gt; &lt;strong&gt;snap&lt;/strong&gt; (selected).&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/1.jpg"&gt; &lt;h6&gt;Step 2&lt;/h6&gt; &lt;p&gt;Grab the &lt;strong&gt;rectangle tool&lt;/strong&gt; and draw a header for it. The height, you have to estimate how much you want. &lt;strong&gt;Balance&lt;/strong&gt; is the main thing you need to concern. Then, apply the blending option as shown below. A &lt;strong&gt;black to white gradient&lt;/strong&gt; with &lt;strong&gt;soft light&lt;/strong&gt; blend mode. Create another rectangle, apply &lt;strong&gt;gradient overlay&lt;/strong&gt; with setting as shown below. Put it &lt;strong&gt;1px&lt;/strong&gt; below the green bar. It will make it more details. Then, draw a &lt;strong&gt;1 pixel line&lt;/strong&gt; and put it right &lt;strong&gt;above&lt;/strong&gt; the gap between the two bars you created before. Give it a darker color.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/2.jpg"&gt; &lt;h6&gt;Step 3&lt;/h6&gt; &lt;p&gt;I use &lt;strong&gt;Myriad Pro&lt;/strong&gt;. So, you guys can edit it by yourself later. Apply &lt;strong&gt;drop shadow&lt;/strong&gt; with the setting shown below. Then, also apply &lt;strong&gt;Gradient Overlay&lt;/strong&gt; with &lt;strong&gt;12% opacity&lt;/strong&gt;, &lt;strong&gt;black to white&lt;/strong&gt;. For the white outline stroke. Simply hold the &lt;strong&gt;CTRL tab&lt;/strong&gt; and &lt;strong&gt;click&lt;/strong&gt; on the text layer to get the selection. Go to &lt;strong&gt;Select &amp;gt; Modify &amp;gt; Contract &amp;gt; 1px&lt;/strong&gt;. After that, &lt;strong&gt;create a new layer&lt;/strong&gt;. Go to &lt;strong&gt;Edit &amp;gt; Stroke &amp;gt; 1px, white, inside&lt;/strong&gt;.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/3.jpg"&gt; &lt;h6&gt;Step 4&lt;/h6&gt; &lt;p&gt;&lt;strong&gt;Draw a rectangle&lt;/strong&gt;, remember, the maximum width you can use is &lt;strong&gt;600px&lt;/strong&gt;. Ok, make its white color. Apply &lt;strong&gt;1px inside white&lt;/strong&gt; stroke. And, &lt;strong&gt;Gradient Overlay&lt;/strong&gt; with the setting as shown below.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/4.jpg"&gt; &lt;h6&gt;Step 5&lt;/h6&gt; &lt;p&gt;The read more button is actually using the same technique where we used for the logo. This time, we apply &lt;strong&gt;Inner Glow&lt;/strong&gt; with &lt;strong&gt;8px&lt;/strong&gt; size and &lt;strong&gt;75% Opacity&lt;/strong&gt; in &lt;strong&gt;Soft Light&lt;/strong&gt; Blend Mode. &lt;strong&gt;Gradient Overlay&lt;/strong&gt; with &lt;strong&gt;70% opacity&lt;/strong&gt; also in &lt;strong&gt;Soft Light&lt;/strong&gt; Blend Mode. Finally, A &lt;strong&gt;1px outside stroke&lt;/strong&gt; with color &lt;strong&gt;#47670b&lt;/strong&gt;. Then, for the &lt;strong&gt;1px inside white stroke&lt;/strong&gt;. It is same with what we did in step 3.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/5.jpg"&gt; &lt;h6&gt;Step 6&lt;/h6&gt; &lt;p&gt;Place in some dummy text and photo. You will have something like this. You can use a text generator for this.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/6.jpg"&gt; &lt;h6&gt;Step 7&lt;/h6&gt; &lt;p&gt;Put in some Dummy Text again. Try to use &lt;strong&gt;none anti-alias font&lt;/strong&gt; for testing. Don’t forget what a wordpress theme needed. Post title, tags, post date, comments number. This time, I add in author photo part to be shown in every post.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/7.jpg"&gt; &lt;h6&gt;Step 8&lt;/h6&gt; &lt;p&gt;Place a RSS icon. I forgot where I downloaded it already…sorry about that… Then, For the search area, create a rounded rectangle with a maximum width of &lt;strong&gt;330px&lt;/strong&gt;. Fill it with &lt;strong&gt;black color&lt;/strong&gt; and set it blend mode to &lt;strong&gt;soft light&lt;/strong&gt;. Create another &lt;strong&gt;rounded rectangle&lt;/strong&gt; inside. This will be our input field. Fill it with &lt;strong&gt;white color&lt;/strong&gt;. Apply &lt;strong&gt;1px inside stroke&lt;/strong&gt; with color – &lt;strong&gt;#d0ceae&lt;/strong&gt;. Then, apply inner Glow, with setting shown below. After that, place the searching icon.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/8.jpg"&gt; &lt;h6&gt;Step 9&lt;/h6&gt; &lt;p&gt;Draw a &lt;strong&gt;rounded rectangle&lt;/strong&gt; and use the pen tool to draw a dialog box as shown below. You can refer to my previous tutorial in LoonDesign on &lt;a href="http://kailoon.com/how-to-create-custom-shape/"&gt;how to create a custom shape&lt;/a&gt; in photoshop. Then, apply &lt;strong&gt;drop shadow&lt;/strong&gt; on it. Use the rectangle tool to create the categories and links content box. The maximum width will be &lt;strong&gt;160px&lt;/strong&gt;. We need a &lt;strong&gt;10px&lt;/strong&gt; space in between them.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/9.jpg"&gt; &lt;h6&gt;Step 10&lt;/h6&gt; &lt;p&gt;We are almost there. Now, we will use the same technique we used to create the header part.&lt;br&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/10.jpg"&gt; &lt;h6&gt;Conclusion&lt;/h6&gt; &lt;p&gt;You may found that I do not mention about the page navigation part. I think it is too simple for you. Try it out yourself. If really can’t, I am also providing the source file for you here. Overall, there is several things we need to consider when creating a wordpress theme. In this example, we are creating for blogging purpose. So, the major section will be, categories, tagging, author photo, comments and also the RSS feed. I prefer to make things more organizes. So, you can found that all the layers in my psd file are well renamed and each section is well separated. This is for future modification purpose and also for my dear reader to modify it easily. &lt;h6&gt;Single Page&lt;/h6&gt; &lt;p&gt;As we are creating theme for wordpress, there must be a single page to display a post and comment section. Here is the final output.&lt;br&gt;&lt;a href="http://themetation.com/img/how1/single-large.jpg"&gt;&lt;img alt="wordpress themes tutorial" src="http://themetation.com/img/how1/single.jpg"&gt;&lt;/a&gt; &lt;h5&gt;Download and continue&lt;/h5&gt; &lt;p&gt;&lt;a href="http://themetation.com/free/theme-sliced.zip"&gt;Download&lt;/a&gt; Continue read on &lt;a href="http://themetation.com/how-to-create-wordpress-themes-from-scratch-part-2"&gt;How To Create WordPress Themes From Scratch Part 2 – Slicing and CSS/XHTML Coding&lt;/a&gt;.  &lt;h3&gt;&amp;nbsp;&lt;/h3&gt; &lt;p&gt;Original post can be found &lt;a href="http://themetation.com/2008/07/14/how-to-create-wordpress-themes-from-scratch-part-1/" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;Related Posts:&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;a title="July 15, 2008" href="http://themetation.com/2008/07/15/how-to-create-wordpress-themes-from-scratch-part-2/" rel="bookmark" linkindex="37"&gt;How To Create WordPress Themes From Scratch Part 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="September 30, 2008" href="http://themetation.com/2008/09/30/our-community/" rel="bookmark" linkindex="38"&gt;Our Community&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="July 17, 2008" href="http://themetation.com/2008/07/17/how-to-create-wordpress-themes-from-scratch-part-3b/" rel="bookmark" linkindex="39"&gt;How To Create WordPress Themes From Scratch Part 3b&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="August 18, 2008" href="http://themetation.com/2008/08/18/themetation-forum-launch/" rel="bookmark" linkindex="40"&gt;Themetation Forum Launch!&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="April 7, 2009" href="http://themetation.com/2009/04/07/65-awesome-wordpress-tutorials/" rel="bookmark" linkindex="41"&gt;60+ Awesome WordPress Tutorials&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="July 17, 2008" href="http://themetation.com/2008/07/17/how-to-create-wordpress-themes-from-scratch-part-3a/" rel="bookmark" linkindex="42"&gt;How To Create WordPress Themes From Scratch Part 3a&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="March 13, 2009" href="http://themetation.com/2009/03/13/our-magazine/" rel="bookmark" linkindex="43"&gt;Our Magazine&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a title="July 17, 2008" href="http://themetation.com/2008/07/17/superfresh/" rel="bookmark" linkindex="44"&gt;SuperFresh&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-7367824465872836304?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/-Z-boBj31wY" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7367824465872836304" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/7367824465872836304" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/-Z-boBj31wY/how-to-create-wordpress-themes-from.html" title="How To Create WordPress Themes From Scratch Part 1" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/how-to-create-wordpress-themes-from.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-3444815188970588717</id><published>2009-07-09T02:32:00.001-07:00</published><updated>2009-07-09T02:33:16.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="MarshalByRefObject" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET Remoting" /><category scheme="http://www.blogger.com/atom/ns#" term="SingleCall" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="Singleton" /><category scheme="http://www.blogger.com/atom/ns#" term="dll" /><title type="text">A Simple Guide to .Net Remoting</title><content type="html">&lt;p&gt;By &lt;a href="http://www.csharpfriends.com/"&gt;jamiemoffat&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;br&gt;Remoting is .Net’s way to create and uses object instances on a remote machine, without any of the hassle of DCOM. &lt;br&gt;This guide provides a (very) quick guide to getting you up and running and calling across your network. Most of the examples that Microsoft provide use a console application to host your remote object, which wouldn’t be the way most of us will use the technology. &lt;br&gt;This tutorial will cover the most common &lt;a href="http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=31#"&gt;hosting&lt;/a&gt; method, which is within IIS. &lt;br&gt;I haven’t gone too deep into all the settings that are available with .Net Remoting, I will cover those in a future article. &lt;br&gt;1) Create a C# class that inherits MarshalByRefObject: E.g. &lt;/p&gt;&lt;pre&gt;&lt;p&gt;&lt;br&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;myObj &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;MarshalByRefObject&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    &lt;span style="color: green"&gt;// ...&lt;br /&gt;&lt;/span&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;br&gt;Add some classes, properties etc. &lt;br&gt;2) Compile it to produce myObj.dll &lt;br&gt;3) Now, the object needs to be hosted somewhere. The easiest way to do this is to host the object within IIS. &lt;br&gt;First of all though, we need to describe our object so it can be accessed. To this end, create a web.config file with the following text: &lt;br&gt;E.g. &lt;pre&gt;&lt;p&gt;&lt;br&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;application&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;service&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;wellknown &lt;/span&gt;&lt;span style="color: red"&gt;mode&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;SingleCall&lt;/span&gt;" &lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;myNamespace.myObj, myObj&lt;/span&gt;"&lt;br /&gt;                        &lt;span style="color: red"&gt;objectUri&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;myObj.soap&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;service&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;application&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;In this XML: &lt;br&gt;type ="myNamespace.myObj, myObj" is the full type name, followed by the assembly name. &lt;br&gt;On the Remote Server: &lt;br&gt;1) Create a directory called “myRemoteObject”. Create a Bin directory beneath it. &lt;br&gt;2) Create a new IIS virtual Directory called myIISObj that points to the myRemoteObject directory. &lt;br&gt;3) Place your compiled versions of myObj.dll in the myRemoteObject \Bin directory &lt;br&gt;4) Place the Web.Config file in the myRemoteObject directory. &lt;br&gt;On the Client: &lt;br&gt;In your application set a reference to the local object on your client machine. This allows he CLR to pick up the meta data of the object so that we can create the object remotely (There is another way to generate the meta data without needing the actual object on the client, a utility called SoapSuds.exe, but I leave that for you to read about ) &lt;br&gt;Now we need a client.config file analogous to the web.config file, which tells the CLR how to access (ie. where to access) the remote object. &lt;pre&gt;&lt;p&gt;&lt;br&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;application &lt;/span&gt;&lt;span style="color: red"&gt;name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Client&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;client &lt;/span&gt;&lt;span style="color: red"&gt;url&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://andy2k/myIISObj&lt;/span&gt;"&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;wellknown &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;myNamespace.myObj, myObj&lt;/span&gt;"&lt;br /&gt;                    &lt;span style="color: red"&gt;url&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http://andy2k/myIISObj/myObj.soap&lt;/span&gt;"&lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;client&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;      &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;channels&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;        &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;channel &lt;/span&gt;&lt;span style="color: red"&gt;ref&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;http&lt;/span&gt;" &lt;span style="color: blue"&gt;/&amp;gt;&lt;br /&gt;      &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;channels&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;    &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;application&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;  &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;system.runtime.remoting&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;br&gt;(Note: replace “andy2k” with the name of your remote server) &lt;br&gt;Now in the client code, simply create the object as usual but, first of all, load the config file. &lt;pre&gt;&lt;p&gt;&lt;br&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;//Load the Http Channel from the config file&lt;br /&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;try&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    RemotingConfiguration.Configure(&lt;span style="color: #a31515"&gt;"client.config"&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: blue"&gt;catch&lt;/span&gt;{}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: green"&gt;//instantiate the remote object on the server&lt;br /&gt;//(this is really just a proxy object here)&lt;br /&gt;&lt;/span&gt;myNamespace.myObj anObj = &lt;span style="color: blue"&gt;new &lt;/span&gt;myNamespace.myObj();&lt;br /&gt;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;The .Net runtime picks up the fact that this is not a local object (because of the config file read in the previous line) and creates the object on the remote machine. You now access the object as if it was created locally, and .Net does the rest. &lt;br&gt;(if you’re not convinced, create a method in the class that simply returns a string representing the name of the local machine &lt;br&gt;Something like: &lt;pre&gt;&lt;p&gt;&lt;br&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public string &lt;/span&gt;getCompName()&lt;br /&gt;{&lt;br /&gt;    &lt;span style="color: blue"&gt;return &lt;/span&gt;System.&lt;span style="color: #2b91af"&gt;Environment&lt;/span&gt;.MachineName;&lt;br /&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;&lt;pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;that should convince you that the object has been created on the remote machine) &lt;br&gt;And there you have it – you’ve just created a remote object!&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=31" target="_blank"&gt;here&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/1002597578696693985-3444815188970588717?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/bD1J4Q-XKiM" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/3444815188970588717" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/3444815188970588717" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/bD1J4Q-XKiM/simple-guide-to-net-remoting.html" title="A Simple Guide to .Net Remoting" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/simple-guide-to-net-remoting.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-1579704014756509076</id><published>2009-07-08T23:02:00.001-07:00</published><updated>2009-09-02T21:09:07.184-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title type="text">Joining Multiple Tables with SQL Inner Join Statements</title><content type="html">&lt;p&gt;You can use SQL JOIN statements to combine data from three or more tables. In an earlier article, we took a look at using &lt;a href="http://databases.about.com/od/sql/l/aajoins2.htm"&gt;inner joins&lt;/a&gt; and &lt;a href="http://databases.about.com/od/sql/l/aajoins3.htm"&gt;outer joins&lt;/a&gt; to combine data from two different tables. In many cases, you’ll want to take this a step further and combine data from three or more tables. Let's take a look at the SQL statements that allow you to accomplish this goal for an inner join. &lt;br&gt;You may recall from our &lt;a href="http://databases.about.com/od/sql/l/aajoins2.htm"&gt;basic inner join example&lt;/a&gt; that the SQL statement below combines data from the Drivers and Vehicles tables in cases where the driver and vehicle are located in the same city:  &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; lastname, firstname, tag&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; drivers, vehicles&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; drivers.location = vehicles.location&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;This query produced the following results: &lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p&gt;lastname firstname tag&lt;br&gt;-------- --------- ---&lt;br&gt;Baker Roland H122JM&lt;br&gt;Smythe Michael D824HA&lt;br&gt;Smythe Michael P091YF&lt;br&gt;Jacobs Abraham J291QR&lt;br&gt;Jacobs Abraham L990MT&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing="0" cellpadding="0" width="375" height="100" border="0" bgcolor="#1C4266"&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align="middle" width="375"&gt;&lt;font color="#0080ff"&gt;Ads by &lt;strong&gt;Nielsen Field&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td align="middle" width="375"&gt;&lt;a title="Nielsen Field Web Solutions, Inc." href="http://www.nielsenfieldwebsolutions.com/" target="_blank"&gt;&lt;img src="http://www.nielsenfieldwebsolutions.com/web20/Skins/Images/nfws_logo.png"&gt;&lt;/a&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;Now, let’s extend this example to include a third table. Imagine that you wanted to include only drivers and vehicles present at locations that are open on the weekend. You could bring a third table into your query by extending the JOIN statement as follows:&lt;/p&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; lastname, firstname, tag, open_weekends&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;FROM&lt;/span&gt; drivers, vehicles, locations&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;WHERE&lt;/span&gt; drivers.location = vehicles.location&lt;/pre&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;AND&lt;/span&gt; vehicles.location = locations.location&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&lt;span class="kwrd"&gt;AND&lt;/span&gt; locations.open_weekends = &lt;span class="str"&gt;'Yes'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;nbsp;&lt;/blockquote&gt;&lt;br /&gt;&lt;blockquote&gt;lastname firstname tag open_weekends&lt;br&gt;-------- --------- --- -------------&lt;br&gt;Baker Roland H122JM yes&lt;br&gt;Jacobs Abraham J291QR yes&lt;br&gt;Jacobs Abraham L990MT yes&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This powerful extension to the basic SQL JOIN statement allows you to combine data in a complex manner. In addition to combining tables with an inner join, you can also use this technique to combine multiple tables using an outer join. As you may recall, outer joins include results that exist in one table but do not have a corresponding match in the joined table. &lt;br /&gt;&lt;h6&gt;Suggested Reading&lt;/h6&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://databases.about.com/library/weekly/aa022501a.htm"&gt;Introducing Joins&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://databases.about.com/od/sql/l/aajoins2.htm"&gt;Inner Joins&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://databases.about.com/library/weekly/aa022501c.htm"&gt;Outer Joins&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Original post can be found &lt;a href="http://databases.about.com/od/sql/a/multiple_joins.htm" target="_blank"&gt;here&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/1002597578696693985-1579704014756509076?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/KFypWCWSMpA" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1579704014756509076" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1579704014756509076" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/KFypWCWSMpA/joining-multiple-tables-with-sql-inner.html" title="Joining Multiple Tables with SQL Inner Join Statements" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/joining-multiple-tables-with-sql-inner.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-8253071177836142662</id><published>2009-07-07T22:07:00.000-07:00</published><updated>2009-07-07T22:09:09.466-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="nopCommerce" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="Open Source" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">nopCommerce Open Source E-Commerce Solution</title><content type="html">&lt;p&gt;nopCommerce is an open source e-commerce solution that contains both a catalog frontend and an administration tool backend. nopCommerce is a fully customizable shopping cart. It's stable and highly usable. From downloads to documentation, nopCommerce.com offers a comprehensive base of information, resources, and support to the nopCommerce community. &lt;p&gt;nopCommerce is new but very popular open source e-commerce solution. nopCommerce is available for free. A solution with comprehensive features that is easy to use for new online businesses, yet powerful enough for the most demanding e-commerce expert. It’s a secure, scalable and extendable e-commerce platform. &lt;p&gt;Create and manage a professional online store with nopCommerce 1.20. Built-in shopping cart, catalog management, credit card processing, shipping calculation, template customization and other powerful tools come standard. &lt;p&gt;So join the &lt;a href="http://www.nopcommerce.com/" target="_blank"&gt;community&lt;/a&gt; and see what you can learn and what you can share!   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1002597578696693985-8253071177836142662?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/BUef3D3sSFU" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/8253071177836142662" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/8253071177836142662" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/BUef3D3sSFU/nopcommerce-open-source-e-commerce.html" title="nopCommerce Open Source E-Commerce Solution" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/nopcommerce-open-source-e-commerce.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-4345148522297077166</id><published>2009-07-07T02:31:00.001-07:00</published><updated>2009-07-07T02:31:18.476-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="Architect" /><category scheme="http://www.blogger.com/atom/ns#" term="framework" /><title type="text">O'Reilly Webcast: Ten Things Every Software Architect Should Know</title><content type="html">This is the slide deck used in Richard Monson-Haefe &lt;a href="http://www.slideshare.net/oreillymedia/oreilly-webcast-ten-things-every-software-architect-should-know#"&gt;more&lt;/a&gt;  &lt;div id="__ss_1048054" style="width: 425px; text-align: left"&gt;&lt;a title="O'Reilly Webcast: Ten Things Every Software Architect Should Know" style="display: block; margin: 12px 0px 3px; font: 14px helvetica,arial,sans-serif; text-decoration: underline" href="http://www.slideshare.net/oreillymedia/oreilly-webcast-ten-things-every-software-architect-should-know"&gt;O'Reilly Webcast: Ten Things Every Software Architect Should Know&lt;/a&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=10thingsfinaldeckfornfjs-1235073615899378-1&amp;amp;stripped_title=oreilly-webcast-ten-things-every-software-architect-should-know" width="425" height="355" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;  &lt;div style="font-size: 11px; padding-top: 2px; font-family: tahoma,arial; height: 26px"&gt;View more &lt;a style="text-decoration: underline" href="http://www.slideshare.net/"&gt;documents&lt;/a&gt; from &lt;a style="text-decoration: underline" href="http://www.slideshare.net/oreillymedia"&gt;oreillymedia&lt;/a&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/1002597578696693985-4345148522297077166?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/Ptm4oDsaUxc" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4345148522297077166" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4345148522297077166" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/Ptm4oDsaUxc/o-webcast-ten-things-every-software.html" title="O&amp;#39;Reilly Webcast: Ten Things Every Software Architect Should Know" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/o-webcast-ten-things-every-software.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-5844839495620536227</id><published>2009-07-06T21:23:00.001-07:00</published><updated>2009-07-06T21:23:55.257-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="TUTORIAL" /><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="Dynamic Data" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title type="text">What is ASP.NET Dynamic Data?</title><content type="html">&lt;p&gt;&lt;a href="http://www.asp.net/dynamicdata"&gt;ASP.NET Dynamic Data&lt;/a&gt; is a technology from Microsoft that expands the toolset of ASP.NET starting with ASP.NET 3.5 SP1. Use it to build data entry web forms that interact with a database or classes that resemble a database.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.peterblum.com/des/dynamicdata.aspx" target="_blank"&gt;READ MORE...&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/1002597578696693985-5844839495620536227?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/wMPClRAvQiU" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5844839495620536227" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/5844839495620536227" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/wMPClRAvQiU/what-is-aspnet-dynamic-data.html" title="What is ASP.NET Dynamic Data?" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/what-is-aspnet-dynamic-data.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-4782898657223034004</id><published>2009-07-01T21:56:00.001-07:00</published><updated>2009-08-13T01:01:07.089-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="developer" /><category scheme="http://www.blogger.com/atom/ns#" term="sample code" /><category scheme="http://www.blogger.com/atom/ns#" term="Open Source" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery" /><title type="text">s3Slider jQuery plugin</title><content type="html">&lt;h4&gt;ABOUT&lt;/h4&gt; &lt;p&gt;The &lt;strong&gt;s3Slider jQuery plugin&lt;/strong&gt; is made by example of &lt;a href="http://smoothslideshow.jondesign.net/timed.html"&gt;jd`s smooth slide show&lt;/a&gt; script. I needed something like that for jQuery (for my web site &lt;a href="http://www.kruskica.net/"&gt;kruskica.net&lt;/a&gt;). Since i didnt find it after a small research i decided to build it by my self.  &lt;h4&gt;HOW TO USE&lt;/h4&gt; &lt;p&gt;It is very easy. First include the jQuery library then include the s3Slider javascript in the head of the page(s) where you want to use s3Slider.  &lt;p&gt;jQuery can be download from &lt;a href="http://docs.jquery.com/Downloading_jQuery"&gt;jQuery`s homepage&lt;/a&gt;.  &lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&amp;lt;script src=&lt;span class="str"&gt;"js/jquery.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;script src=&lt;span class="str"&gt;"js/s3Slider.js"&lt;/span&gt; type=&lt;span class="str"&gt;"text/javascript"&lt;/span&gt;&amp;gt;&amp;lt;/script&amp;gt; &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; For the script to work properly there is a set of rules that must be followed. &lt;br /&gt;&lt;h5&gt;HTML&lt;/h5&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="s3slider"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;   &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="s3sliderContent"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="s3sliderImage"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="#"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Your text comes here&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="s3sliderImage"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="#"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;Your text comes here&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;span&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;li&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="clear s3sliderImage"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;   &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ul&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://www.serie3.info/s3slider/#"&gt;+ show all of the code&lt;/a&gt; &lt;br /&gt;&lt;h6&gt;Explanation&lt;/h6&gt;&lt;br /&gt;&lt;p&gt;If you set that main div id is s3slider as we did here, that is the name that must be prefix for all other classes and id`s for that specific gallery (slide show). For example, if you set an id for main div as your_name, the inner id must be your_nameContent and the class .your_nameImage like in example above. &lt;br /&gt;&lt;p&gt;The second thing is that every .your_nameImage element in it self must have span. Also, the last div with class clear must also have an class of image holder in this case .your_nameImage. if you dont put that, the last image will &lt;strong&gt;NOT&lt;/strong&gt; be shown in the slide show. &lt;br /&gt;&lt;h5&gt;CSS&lt;/h5&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;#s3slider { &lt;/pre&gt;&lt;pre&gt;   width: 400px; /* important to be same as image width */ &lt;/pre&gt;&lt;pre class="alt"&gt;   height: 300px; /* important to be same as image height */&lt;/pre&gt;&lt;pre&gt;   position: relative; /* important */&lt;/pre&gt;&lt;pre class="alt"&gt;   overflow: hidden; /* important */&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;#s3sliderContent {&lt;/pre&gt;&lt;pre&gt;   width: 400px; /* important to be same as image width or wider */&lt;/pre&gt;&lt;pre class="alt"&gt;   position: absolute; /* important */&lt;/pre&gt;&lt;pre&gt;   top: 0; /* important */&lt;/pre&gt;&lt;pre class="alt"&gt;   margin-left: 0; /* important */&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;.s3sliderImage {&lt;/pre&gt;&lt;pre&gt;   float: left; /* important */&lt;/pre&gt;&lt;pre class="alt"&gt;   position: relative; /* important */&lt;/pre&gt;&lt;pre&gt;   display: none; /* important */&lt;/pre&gt;&lt;pre class="alt"&gt;}&lt;/pre&gt;&lt;pre&gt;.s3sliderImage span {&lt;/pre&gt;&lt;pre class="alt"&gt;   position: absolute; /* important */&lt;/pre&gt;&lt;pre&gt;   left: 0;&lt;/pre&gt;&lt;pre class="alt"&gt;   font: 10px/15px Arial, Helvetica, sans-serif;&lt;/pre&gt;&lt;pre&gt;   padding: 10px 13px;&lt;/pre&gt;&lt;pre class="alt"&gt;   width: 374px;&lt;/pre&gt;&lt;pre&gt;   background-color: #000;&lt;/pre&gt;&lt;pre class="alt"&gt;   filter: alpha(opacity=70); /* here you can set the opacity of box with text */&lt;/pre&gt;&lt;pre&gt;   -moz-opacity: 0.7; /* here you can set the opacity of box with text */&lt;/pre&gt;&lt;pre class="alt"&gt;   -khtml-opacity: 0.7; /* here you can set the opacity of box with text */&lt;/pre&gt;&lt;pre&gt;   opacity: 0.7; /* here you can set the opacity of box with text */&lt;/pre&gt;&lt;pre class="alt"&gt;   color: #fff;&lt;/pre&gt;&lt;pre&gt;   display: none; /* important */&lt;/pre&gt;&lt;pre class="alt"&gt;   top: 0;&lt;/pre&gt;&lt;pre&gt;   /*&lt;/pre&gt;&lt;pre class="alt"&gt;       if you put&lt;/pre&gt;&lt;pre&gt;       top: 0; -&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; the box with text will be shown at the top of the image &lt;/pre&gt;&lt;pre class="alt"&gt;       if you put&lt;/pre&gt;&lt;pre&gt;       bottom: 0; -&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; the box with text will be shown at the bottom of the image&lt;/pre&gt;&lt;pre class="alt"&gt;   */&lt;/pre&gt;&lt;pre&gt;}&lt;/pre&gt;&lt;pre class="alt"&gt;.clear {&lt;/pre&gt;&lt;pre&gt;   clear: both;&lt;/pre&gt;&lt;pre class="alt"&gt;} &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://www.serie3.info/s3slider/#"&gt;+ show all of the code&lt;/a&gt; &lt;br /&gt;&lt;p&gt;Then you need to initalize s3Slider and set the duration of how long will one picture be shown on the page (value is in miliseconds). &lt;br /&gt;&lt;h5&gt;JS&lt;/h5&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;pre class="alt"&gt;$(document).ready(&lt;span class="kwrd"&gt;function&lt;/span&gt;() { &lt;/pre&gt;&lt;pre&gt;   $(&lt;span class="str"&gt;'#s3slider'&lt;/span&gt;).s3Slider({ &lt;/pre&gt;&lt;pre class="alt"&gt;      timeOut: 4000 &lt;/pre&gt;&lt;pre&gt;   });&lt;/pre&gt;&lt;pre class="alt"&gt;}); &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Take a look at the &lt;a href="http://www.serie3.info/s3slider/demonstration.html"&gt;live example&lt;/a&gt;. &lt;br /&gt;&lt;h4&gt;COPYRIGHT&lt;/h4&gt;&lt;br /&gt;&lt;p&gt;This script is licensed under &lt;strong&gt;Creative Commons Attribution 2.5&lt;/strong&gt;. So you can use it in all you projects even commercial ones. &lt;br /&gt;&lt;p&gt;More example:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a title="http://www.jsconf2009.com/" href="http://www.jsconf2009.com/"&gt;http://www.jsconf2009.com/&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/1002597578696693985-4782898657223034004?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/nYgNJiHeZpc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://developercontainer.blogspot.com/feeds/4782898657223034004/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1002597578696693985&amp;postID=4782898657223034004" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4782898657223034004" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/4782898657223034004" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/nYgNJiHeZpc/s3slider-jquery-plugin.html" title="s3Slider jQuery plugin" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://developercontainer.blogspot.com/2009/07/s3slider-jquery-plugin.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-8054715366546392712</id><published>2009-06-30T21:34:00.001-07:00</published><updated>2009-06-30T21:45:50.028-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="logging tool" /><title type="text">Kill Bugs Like a Frog</title><content type="html">&lt;p&gt;GIBRALTAR is very cool! Learn more on their &lt;a href="http://www.gibraltarsoftware.com/Enter/LearnMore.aspx" target="_blank"&gt;website&lt;/a&gt;.&lt;/p&gt; &lt;h3&gt;Part logging tool, part application monitor, part profiler.All frog. &lt;/h3&gt; &lt;p&gt;Gibraltar isn't really a frog, and it won't turn you into one, either. It just reminds us of one with its simple, natural bug-spotting powers. You can also think of Gibraltar as a flight recorder that monitors your .NET applications making it easier for you to test and support them.  &lt;p&gt;We're proud of Gibraltar, and we'd like to tell you &lt;a href="http://www.gibraltarsoftware.com/Enter/LearnMore.aspx"&gt;more about it&lt;/a&gt;. You can &lt;a href="http://www.gibraltarsoftware.com/Register_Now.aspx"&gt;download a full-featured trial now&lt;/a&gt;, or check out this short video to learn how Gibraltar can streamline your software testing and support processes for any .NET application.  &lt;p&gt;Gibraltar records and sends error and usage information to your support staff and provides powerful, yet simple analysis and visualization tools so you can &lt;b&gt;triage customer issues&lt;/b&gt; faster, better &lt;b&gt;optimize development priorities&lt;/b&gt; and continuously &lt;b&gt;improve software quality&lt;/b&gt;.  &lt;p&gt;With Gibraltar, you will find and kill software bugs faster and easier than ever before. You'll also provide more effective customer support and have new insights into how users interact with your applications.  &lt;p&gt;So please, click the large triangular play button to the right and &lt;b&gt;watch a short video demonstration of Gibraltar in action&lt;/b&gt;. Or click the links to &lt;a href="http://www.gibraltarsoftware.com/Enter/LearnMore.aspx"&gt;learn more&lt;/a&gt;, or &lt;a href="http://www.gibraltarsoftware.com/Register_Now.aspx"&gt;download a free trial&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Original post can be found &lt;a href="http://www.gibraltarsoftware.com/ads/w4a.aspx" target="_blank"&gt;here&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/1002597578696693985-8054715366546392712?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/9j6_Y8ti7_U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://developercontainer.blogspot.com/feeds/8054715366546392712/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1002597578696693985&amp;postID=8054715366546392712" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/8054715366546392712" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/8054715366546392712" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/9j6_Y8ti7_U/kill-bugs-like-frog.html" title="Kill Bugs Like a Frog" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://developercontainer.blogspot.com/2009/06/kill-bugs-like-frog.html</feedburner:origLink></entry><entry><id>tag:blogger.com,1999:blog-1002597578696693985.post-1045060027799352139</id><published>2009-06-26T08:24:00.001-07:00</published><updated>2009-06-26T08:25:44.944-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Creational Patterns" /><category scheme="http://www.blogger.com/atom/ns#" term="Singleton" /><title type="text">Creational Patterns - Singleton</title><content type="html">&lt;p&gt;By&amp;nbsp; &lt;a href="http://www.c-sharpcorner.com/"&gt;Susan Abraham&lt;/a&gt; May 31, 2005 &lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt; &lt;p&gt;Most programming involves usage of Design Patterns in one form or other .There are around 23 Design Patterns that are available. They are categorized as given below: &lt;p&gt;I] Creational Patterns  &lt;ol&gt; &lt;li&gt;Singleton &lt;li&gt;Factory  &lt;li&gt;Abstract Factory &lt;li&gt;Builder &lt;li&gt;Prototype&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;II] Structural Patterns &lt;ol&gt; &lt;li&gt;Adapter  &lt;li&gt;Bridge  &lt;li&gt;Composite  &lt;li&gt;Decorator  &lt;li&gt;Facade  &lt;li&gt;Flyweight  &lt;li&gt;Proxy&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;III] Behavioral Pattern &lt;ol&gt; &lt;li&gt;Chain Of Responsibility  &lt;li&gt;Command  &lt;li&gt;Interpreter  &lt;li&gt;Iterator  &lt;li&gt;Mediator  &lt;li&gt;Memento  &lt;li&gt;Observer  &lt;li&gt;State  &lt;li&gt;Strategy  &lt;li&gt;Template Method  &lt;li&gt;Visitor&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;This paper discusses the implementation of the Singleton Design Pattern. &lt;p&gt;&lt;strong&gt;The Concept&lt;/strong&gt; &lt;p&gt;Design patterns are commonly defined as time-tested solutions to recurring design problems. &lt;p&gt;The most striking benefits of Design Patterns are as follows: &lt;ul&gt; &lt;li&gt;They provide you with a way to solve issues related to software development using a proven solution. The solution facilitates the development of highly cohesive modules with minimal coupling. They isolate the variability that may exist in the system requirements, making the overall system easier to understand and maintain.  &lt;li&gt;Design patterns make communication between designers more efficient. Software professionals can immediately picture the high-level design in their thoughts immediately the name of the pattern used to solve a particular issue when discussing system design&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Singleton Pattern&lt;/strong&gt;: In the Singleton Pattern we have at any given instance a single instance of the Singleton Class active. All instantiation of the Singleton Class references the same instance of the Class. The pattern also provides a global point of access to the sole instance of the class. &lt;p&gt;&lt;strong&gt;Class Diagram&lt;/strong&gt; &lt;p&gt;&lt;img alt="" hspace="0" src="http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns06042005050058AM/Images/CR1.gif" align="baseline" border="0"&gt; &lt;p&gt;&lt;strong&gt;Sequence Diagram&lt;/strong&gt; &lt;p&gt;&lt;img alt="" hspace="0" src="http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns06042005050058AM/Images/CR2.gif" align="baseline" border="0"&gt; &lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt; &lt;p&gt;Steps for implementing the Singleton Pattern: &lt;p&gt;&lt;strong&gt;Step1:&lt;/strong&gt;&lt;br&gt;Create a project of type Console Application. Name it SingletonTest. &lt;p&gt;&lt;strong&gt;Step2:&lt;br&gt;&lt;/strong&gt;Add a Class File named Singleton and add the following code &lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// Summary description for Singleton.&lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;public class Singleton&lt;br&gt;{&lt;br&gt;//Fields&lt;br&gt;private static Singleton instance;&lt;br&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// Standard default Constructor &lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;protected Singleton() {}&lt;br&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// Static method for creating the single instance &lt;br&gt;/// of the Constructor&lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;public static Singleton Instance()&lt;br&gt;{&lt;br&gt;// initialize if not already done &lt;br&gt;if( instance == null )&lt;br&gt;instance = new Singleton();&lt;br&gt;// return the initialized instance of the Singleton Class&lt;br&gt;return instance;&lt;br&gt;}&lt;br&gt;}  &lt;p&gt;&lt;strong&gt;Step 3:&lt;br&gt;&lt;/strong&gt;Create a Client class that would access the Singleton Class as follows : &lt;p&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// Summary description for Client.&lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;class Client&lt;br&gt;{&lt;br&gt;/// &amp;lt;summary&amp;gt;&lt;br&gt;/// The main entry point for the application.&lt;br&gt;/// &amp;lt;/summary&amp;gt;&lt;br&gt;[STAThread]&lt;br&gt;static void Main(string[] args)&lt;br&gt;{&lt;br&gt;// Constructor is protected -- cannot use new&lt;br&gt;Singleton s1 = Singleton.Instance();&lt;br&gt;Singleton s2 = Singleton.Instance();&lt;br&gt;if( s1 == s2 )&lt;br&gt;Console.WriteLine( "The same instance" );&lt;br&gt;Console.ReadLine();&lt;br&gt;}&lt;br&gt;} &lt;p&gt;&lt;strong&gt;Step 4:&lt;br&gt;&lt;/strong&gt;Run the Application it would display the following output: &lt;p&gt;&lt;img alt="" hspace="0" src="http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns06042005050058AM/Images/CR31.gif" align="baseline" border="0"&gt; &lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt; &lt;p&gt;Thus we have implemented the Singleton Design Pattern using the .Net framework.Like any Concepts/Theory Singleton Pattern also has its pros and cons.  &lt;p&gt;&lt;strong&gt;Benefits of Singleton Pattern:&lt;/strong&gt; &lt;ol&gt; &lt;li&gt;Instance control: Singleton prevents other objects from instantiating their own copies of the Singleton object, ensuring that all objects access the single instance. &lt;li&gt;Flexibility: Because the class controls the instantiation process, the class has the flexibility to change the instantiation process.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;Drawbacks of Singleton Pattern:&lt;/strong&gt; &lt;ol&gt; &lt;li&gt;Overhead. Although the amount is minuscule, there is some overhead involved in checking whether an instance of the class already exists every time an object requests a reference. This problem can be overcome by using static initialization. &lt;li&gt;Possible development confusion. When using a singleton object (especially one defined in a class library), developers must remember that they cannot use the new keyword to instantiate the object. Because application developers may not have access to the library source code, they may be surprised to find that they cannot instantiate this class directly. &lt;li&gt;Object lifetime. Singleton does not address the issue of deleting the single object. In languages that provide memory management (for example, languages based on the .NET Framework), only the Singleton class could cause the instance to be deallocated because it holds a private reference to the instance. In languages, such as C++, other classes could delete the object instance, but doing so would lead to a dangling reference inside the Singleton class.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Original Post can be found &lt;a href="http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns06042005050058AM/CreationalPatterns.aspx"&gt;here&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/1002597578696693985-1045060027799352139?l=developercontainer.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DeveloperStuff/~4/sn-1F4QjdoE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://developercontainer.blogspot.com/feeds/1045060027799352139/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=1002597578696693985&amp;postID=1045060027799352139" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1045060027799352139" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1002597578696693985/posts/default/1045060027799352139" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DeveloperStuff/~3/sn-1F4QjdoE/creational-patterns-singleton.html" title="Creational Patterns - Singleton" /><author><name>ramil</name><uri>http://www.blogger.com/profile/17445191350548842437</uri><email>objectorientedprog@gmail.com</email><gd:extendedProperty xmlns:gd="http://schemas.google.com/g/2005" name="OpenSocialUserId" value="03079780593961956334" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://developercontainer.blogspot.com/2009/06/creational-patterns-singleton.html</feedburner:origLink></entry></feed>
