<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Sanjeetosphere</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sanjeets/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sanjeets/feed.xml</link>
    <description>Sanjeet&amp;#039;s technical outbursts.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:25:16 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Coherence With .Net</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/coherence-with-net</link>
      <pubDate>Wed, 09 Jul 2008 04:26:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2008/07/09/coherence-with-net/</guid>
      <description><![CDATA[In one of my recent
projects I was implementing Enterprise level caching using Coherence....]]></description>
      <content:encoded><![CDATA[

<p>In one of my recent
projects I was implementing Enterprise level caching using <a href="https://www.oracle.com/products/middleware/coherence/index.html" target="_blank" title="Coherence" id="i-lb">Coherence</a>. <br id="zbk:">
<br id="zbk:0">
As you might be aware its written in Java and expects all the objects
(that needs to be cached in it) in a Portable Object Format. This is to allow
interoperability and platform independence. If the client is Java, the <a href="https://wiki.tangosol.com/display/COHNET32/Home" target="_blank" title="POF" id="i1uu">POF</a> isn't mandatory, however if
its .Net it is mandatory.<br id="zbk:1">
<br id="zbk:2">
Things weren't too good to start with. I personally do not favor
any platform for getting certain things done, but the fact of the matter is
that Microsoft excels in product support. If you can find issues with any
product, you are most likely to find remedies over the support site. With
Coherence, and Oracle I am afraid things aren't the way they should. They need
some effort here.<br id="b9xm">
<br id="b9xm0">
The issues I faced while implementing the solution are:<br id="b9xm1">
- Although my .Net class was derived from IPortableObject, I
wasn't able to serialize int!!! There was no issue with strings. The error
message was as generic as it can ever get - Java.Io.IoException: Unable to
convert type -20 to a binary type. If you do a search you will not find
anything helpful.<br id="xqlu">
- If I tried to use one more class, it failed with the message:
Unable to load type 1002. Please note that its suggested in the documents that
custom user type IDs should be greater that 1000. So, my first type Employee
was 1001, and the second type Contractor was 1002. It failed miserably, and
like earlier found nothing over the Web.<br id="u:sx">
<br id="u:sx0">
So, I decided to try something else, knowing the fact that it
needs objects in binary format, I used the following:<br id="mg7g">
<br id="tdxk">
- Decorated the class in question with [Serializable] attribute<br id="tdio10">
&nbsp;&nbsp;&nbsp; [Serializable]<br id="o5uo0">
&nbsp; public class
Contractor : IPerson,
IPortableObject<br id="tdxk0">
<br id="b053">
- Created the object and initialized it with values<br id="pw9:">
&nbsp;&nbsp; IPerson
contractor = new Contractor();<br id="pw9:0">
&nbsp; contractor.Name = "ABC";<br id="pw9:1">
&nbsp; contractor.Address = "Karol Bagh";<br id="pw9:2">
&nbsp; contractor.DoB = DateTime.Now;<br id="gztk">
<br id="bvac">
- Initialized the cache<br id="q79j">
&nbsp;&nbsp;&nbsp;&nbsp;cache
= CacheFactory.GetCache("dist-session-cache");<br id="bvac0">
<br id="bvac1">
- Created a binary formatter, a memory stream, serialized the object,
and then inserted the array of bytes in binary format in the Coherence cache.<br id="q79j0">
&nbsp; BinaryFormatter
binFormat = new BinaryFormatter();<br id="q79j1">
&nbsp; MemoryStream memStream
= new MemoryStream();<br id="q79j2">
&nbsp; binFormat.Serialize(memStream, contractor);<br id="q79j3">
&nbsp; byte[]
array = memStream.ToArray();<br id="q79j4">
&nbsp; cache.Insert(1, array);<br id="vkcw">
<br id="vkcw0">
- To deserilaize, I did the following:<br id="vkcw1">
&nbsp; byte[]
cachedObject = cache[1] as byte[];<br id="vkcw3">
&nbsp; MemoryStream memStreamFromCache = new MemoryStream(cachedObject);<br id="vkcw6">
&nbsp; IPerson p = (IPerson)binFormat.Deserialize(memStreamFromCache);<br id="h6i2">
<br id="h6i20">
<br id="h6i21">
I am sure this is going to be helpful for all those using Coherence
with .Net<br id="mlie0">
<br id="mlie1">
See you soon with Splunk.</p>



]]></content:encoded>
    </item>
    <item>
      <title>A walk in the park</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/a-walk-in-the-park</link>
      <pubDate>Thu, 22 May 2008 05:45:00 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2008/05/22/a-walk-in-the-park/</guid>
      <description><![CDATA[I have written some Domain specific blogs. You can find them here:https://sanjeetsahay.blogspot.comI...]]></description>
      <content:encoded><![CDATA[<p>I have written some Domain specific blogs. You can find them here:</p><p>https://sanjeetsahay.blogspot.com</p><p>I will resume my postings on Patterns and Frameworks soon. Till then :)<br></p><p>&nbsp;</p><p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Creational - Factory Pattern</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/creational-factory-pattern</link>
      <pubDate>Sun, 02 Sep 2007 09:22:40 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/09/02/creational-factory-pattern/</guid>
      <description><![CDATA[In continuation to my previous post, I am presenting you a sample code that implements Factory...]]></description>
      <content:encoded><![CDATA[<p>In continuation to my previous post, I am presenting you a sample code that implements Factory Pattern.  <p>The overview:<br>&nbsp;- We are using the Person, Gift and Letter classes as we did in the Abstract Factory Pattern implementation. This is just to show how you can use the same scenario against different patterns.<br>&nbsp;- The abstract Person class is the Creator. Gift and Letter are Products.<br>&nbsp;- The concrete creator classes are Employee and Colleague. The concrete Product classes are: Email, Postal for Letter; Flowers, Perfume for Gift.<br>&nbsp;- The Creator has 2 abstract functions that create Products. the Concrete Classes override them to create different Products.<br>&nbsp;- You can create an Array of Concrete objects for the Creator class.  <p>Takeaways:<br>&nbsp;- This pattern is particularly helpful in designing frameworks.<br>&nbsp;- The Creator relies on its subclasses to define the factory method to return the appropriate ConcreteProduct.<br>&nbsp;- There is no Client class.  <p>The Creator Class:</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 63.32%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 126px; background-color: #f4f4f4; max-height: 200px"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> Gift CreateGift();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> Letter CreateLetter();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     }</pre></div></div>
<p>The Concrete Classes:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 63.06%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 218px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Employee: Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Gift CreateGift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Flowers();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Letter CreateLetter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Email();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Colleague: Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Gift CreateGift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>             <span style="color: #008000">//throw new NotImplementedException();</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Perfume();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Letter CreateLetter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>             <span style="color: #008000">//throw new NotImplementedException();</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Postal();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>     }</pre></div></div>
<p>The Products - Letter and Gift; Concrete Products Email, Postal, Flowers, and Perfume</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 63.22%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 217px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> Letter</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Email: Letter</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">public</span> Email()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>             Console.WriteLine(<span style="color: #006080">"Email Created"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Postal: Letter</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #0000ff">public</span> Postal()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>             Console.WriteLine(<span style="color: #006080">"Postal Created"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> Gift</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     {        </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Flowers: Gift</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #0000ff">public</span> Flowers()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>             Console.WriteLine(<span style="color: #006080">"Flowers Created"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Perfume: Gift</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>         <span style="color: #0000ff">public</span> Perfume()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>             Console.WriteLine(<span style="color: #006080">"Perfume Created"</span>);</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span>     }</pre></div></div>
<p>The usage from within application:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 63.6%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 205px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>             Person[] people = <span style="color: #0000ff">new</span> Person[2];</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>             people[0] = <span style="color: #0000ff">new</span> Employee();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>             people[1] = <span style="color: #0000ff">new</span> Colleague();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>             </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>             <span style="color: #0000ff">foreach</span>(Person person <span style="color: #0000ff">in</span> people)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>                 Console.WriteLine(person.CreateGift());</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>                 person.CreateLetter();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>             Console.Read();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         }</pre></div></div>
<p>Hope it helps. Do write to me in case of any question/suggestions.</p>]]></content:encoded>
    </item>
    <item>
      <title>Software Design Patterns - Creational Patterns</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/software-design-patterns-creational-patterns</link>
      <pubDate>Sun, 02 Sep 2007 08:07:55 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/09/02/software-design-patterns-creational-patterns/</guid>
      <description><![CDATA[This happens to be the first of my articles on Software Design Patterns. I will present some basics...]]></description>
      <content:encoded><![CDATA[<p><font face="Segoe UI" size="2"></font></p> <p><font face="Segoe UI" size="2">This happens to be the first of my articles on Software Design Patterns. I will present some basics followed by implementation of the pattern.</font>  <p><font face="Segoe UI" size="2">These patterns help make a system independent of how its objects are created, composed and represented.<br>A class creational pattern uses inheritance to vary the class that’s instantiated, whereas the object creational pattern will delegate instantiation to another object. </font> <p><font face="Segoe UI" size="2">In creational patterns emphasis shifts away from hard coding a fixed set of behaviors towards defining a smaller set of fundamental behaviors that can be composed into any number of more complex ones. Thus object composition becomes more important than class inheritance.<br>Some widely used patterns in this category are: </font> <p><font size="2"><font face="Segoe UI"><strong>Abstract Factory</strong><br>&nbsp;- The main purpose is to create objects for the product class.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- The break-up of classes involved is as follows:<br>&nbsp; &gt; You need an abstract factory class which acts as a base to some concrete classes.<br>&nbsp; &gt; You need an abstract product/entity class which will act as a base class for some fixed number of concrete product classes.<br>&nbsp; &gt; A client, which always uses the interfaces declared by the abstract factory and product classes.<br>&nbsp; &gt; The factory class is not abstract; it in fact uses the Singleton pattern to create only 1 instance. It is used by the product classes to create new instances.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- You can use this pattern in the following cases:<br>&nbsp; &gt; A system is independent in terms of how its products are created, composed and represented.<br>&nbsp; &gt; You want to provide a class library of things, and you don’t want to reveal the implementations but interfaces.<br>&nbsp; &gt; The number of products is defined.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- Advantages:<br>&nbsp; &gt; Concrete classes are isolated. Product class names are isolated in the implementation of the concrete factory.<br>&nbsp; &gt; Product families can be changed easily.<br>&nbsp; &gt; Promotes consistency among products.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- Disadvantages:<br>&nbsp; &gt; Supporting new kinds of products is difficult. It requires you to change the abstract and concrete factory classes at number of places. </font></font></p> <p><font size="2"><font face="Segoe UI"><strong>Factory</strong><br>&nbsp;- This pattern defines an interface for creating an object, but let subclasses decide which class to instantiate.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- The break-up of the classes involved is as follows:<br>&nbsp; &gt; You need a Product and a Creator<br>&nbsp; &gt; Concrete classes for Product and Creator.<br>&nbsp; &gt; Creator relies on its subclasses to define factory method so that it returns an instance of the appropriate Concrete Product.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- The following happens:<br>&nbsp; &gt; You may create multiple Creator classes, and multiple Product classes.<br>&nbsp; &gt; Each Creator has something like a Create() function that creates one/more Products.<br>&nbsp; &gt; From a client, you create an array of Creator base abstract class. This array can have objects from any of the inherited Creator classes.<br>&nbsp; &gt; The inherited Creator classes then create one/more Products for the client. </font></font></p> <p><font size="2"><font face="Segoe UI"><strong>Builder</strong><br>&nbsp;- This pattern is useful when you want to separate the construction of a complex object from its representation. This enables the same construction process to create different representations.<br>&nbsp;- It involves a <em>Builder</em> and a <em>Director</em>.<br>&nbsp;- Use this pattern if:<br>&nbsp; &gt; You need to keep the algorithm of creating a complex object separate from the parts that make it up.<br>&nbsp; &gt; The construction process must allow different representations for the object that’s constructed.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- The break-up of the classes involved are as follows:<br>&nbsp; &gt; There is an abstract builder class for creating parts of a product object.<br>&nbsp; &gt; You need a Concrete Builder class to construct and assemble parts of the product by implementing Builder.<br>&nbsp; &gt; A Director class that constructs an object by using the Builder.<br>&nbsp; &gt; The Product classes that represent the complex object under construction. They do not require an Abstract base class as their implementations have to be very different.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- The following happens:<br>&nbsp; &gt; A client creates the Director object and configures it with the desired Builder object.<br>&nbsp; &gt; Director notifies the Builder to build a Product. Builder then adds parts to the Product.<br>&nbsp; &gt; The client retrieves the Product from the builder.</font></font></p> <p><font size="2"><font face="Segoe UI">&nbsp;- Advantages:<br>&nbsp; &gt; Director has no direct interaction with the Product so you can easily change/modify them.<br>&nbsp; &gt; It isolates the code for construction and representation.<br>&nbsp; &gt; This pattern constructs products step by step under Director’s control.</font></font></p> <p><font size="2"><br><br><font face="Segoe UI"></font></font></p>]]></content:encoded>
    </item>
    <item>
      <title>Creational - Abstract factory Pattern</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/creational-abstract-factory-pattern</link>
      <pubDate>Sun, 02 Sep 2007 07:47:31 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/09/02/creational-abstract-factory-pattern/</guid>
      <description><![CDATA[In continuation to my previous post, I am presenting you a sample code that implements Abstract...]]></description>
      <content:encoded><![CDATA[<p>In continuation to my previous post, I am presenting you a sample code that implements Abstract Factory Pattern.  <p>The overview:<br>&nbsp;- This implementation contains a factory called Person.<br>&nbsp;- The Product/Entity class is represented by 2 abstract classes called Gift and Letter.<br>&nbsp;- The client class is called Client.<br>&nbsp;- Employee and Colleague inherits from Person.<br>&nbsp;- Email inherits Letter and Flowers inherit Gift.<br>&nbsp;- Client creates/receives an instance of Person class which creates objects for Gift and Letter.  <p>Takeaways:<br>&nbsp;- As discussed earlier, Creational Patterns focus on creating objects of Product.<br>&nbsp;- The complexity of this pattern increases as the number of Product increases. You have to add more virtual functions at the Person(Factory) level. Then override those functions at the Concrete classes of the Factory(eg., Employee, Colleague)  <p>The Person class(Factory), this implementation uses the Singleton pattern with Lazy Initialization to make sure that there is only 1 instance in the application.</p> <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 68.04%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 192px; background-color: #f4f4f4; max-height: 200px"> <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         <span style="color: #008000">/// Static variable of the class to see if its already instantiated</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Person _p;      </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #008000">/// The virual functions to create a Gift Product</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> Gift CreateGift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Flowers();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #008000">/// The virual functions to create a Letter Product</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> Letter CreateLetter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Email();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #008000">/// This static method gets you the single instance of this class</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Person GetInstance()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>             <span style="color: #0000ff">if</span> (_p == <span style="color: #0000ff">null</span>)</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>                 _p = <span style="color: #0000ff">new</span> Person();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>             <span style="color: #0000ff">return</span> _p;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  40:</span>         <span style="color: #008000">/// Constructor with restricted access</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  41:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  42:</span>         <span style="color: #0000ff">protected</span> Person(){</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  43:</span>         }        </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  44:</span>     }</pre></div></div>
<p>The Employee Concrete Class:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 68.02%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 207px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     <span style="color: #008000">/// This is one of the Concrete classes which isolated from the client</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Employee: Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #008000">/// Constructor to the class</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">public</span> Employee():<span style="color: #0000ff">base</span>()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>             </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #008000">/// Override the virtual declared in the base class.</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         <span style="color: #008000">/// This function creates and returns one of the products - Flowers</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Gift CreateGift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Flowers();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         <span style="color: #008000">/// Override the virtual declared in the base class.</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         <span style="color: #008000">/// This function creates and returns one of the products - Email</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Letter CreateLetter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Email();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>     }</pre></div></div>
<p>The Colleague Concrete Class:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 68.77%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 207px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     <span style="color: #008000">/// This is one of the Concrete classes which isolated from the client</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Colleague: Person</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         <span style="color: #008000">/// Constructor to the class</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">public</span> Colleague():<span style="color: #0000ff">base</span>()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         <span style="color: #008000">/// Override the virtual declared in the base class.</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         <span style="color: #008000">/// This function creates and returns one of the products - Flowers</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Gift CreateGift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Flowers();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>         <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         <span style="color: #008000">/// Override the virtual declared in the base class.</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         <span style="color: #008000">/// This function creates and returns one of the products - Email</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> Letter CreateLetter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>             <span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span> Email();</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>     }</pre></div></div>
<p>The Gift and Letter&nbsp;Abstract Product Classes:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 69.13%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 209px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     <span style="color: #008000">/// This is the Product type #1</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> Gift</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     { </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">protected</span> <span style="color: #0000ff">string</span> _name;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">string</span> Name</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>             get;set;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>              </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>         <span style="color: #0000ff">public</span> Gift()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>             _name = <span style="color: #006080">"Gift Constructor"</span>;        </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>         }        </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     } </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     <span style="color: #008000">/// This is the Product type #2</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> Letter</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         <span style="color: #0000ff">protected</span> <span style="color: #0000ff">string</span> _purpose;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>                 </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         <span style="color: #0000ff">public</span> Letter()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>             _purpose = <span style="color: #006080">"Letter Constructor"</span>;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">virtual</span> <span style="color: #0000ff">string</span> Purpose</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>             get;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>             set;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>     }</pre></div></div>
<p>The Products - Email and Flowers:</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 69.66%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 204px; background-color: #f4f4f4; max-height: 200px">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     <span style="color: #008000">/// This is product #1 of product type #1</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Flowers: Gift</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         <span style="color: #0000ff">public</span> Flowers()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>             _name = <span style="color: #006080">"Flowers Constructor"</span>;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>         </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">string</span> Name</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>             get</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>                 <span style="color: #0000ff">return</span> _name;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>             set</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>                 _name = <span style="color: #0000ff">value</span>;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>         }      </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span> &nbsp;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span> <span style="color: #008000">/// &lt;summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>     <span style="color: #008000">/// This is product #1 of product type #2</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>     <span style="color: #008000">/// &lt;/summary&gt;</span></pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>     <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Email: Letter</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>     {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>     </pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         <span style="color: #0000ff">public</span> Email()</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>             _purpose = <span style="color: #006080">"Email Constructor"</span>;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>         <span style="color: #0000ff">public</span> <span style="color: #0000ff">override</span> <span style="color: #0000ff">string</span> Purpose</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>         {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>             get</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>                 <span style="color: #0000ff">return</span> _purpose;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  40:</span>             set</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  41:</span>             {</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  42:</span>                 _purpose = <span style="color: #0000ff">value</span>;</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  43:</span>             }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  44:</span>         }</pre><pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  45:</span>     }</pre></div></div>
<p>&nbsp;</p>
<p>Please write to me if you have any questions/suggestions.</p>]]></content:encoded>
    </item>
    <item>
      <title>How To: Use SqlMetal.exe to Create a Class from XML and Database</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/how-to-use-sqlmetal-exe-to-create-a-class-from-xml-and-database</link>
      <pubDate>Thu, 07 Jun 2007 04:23:48 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/06/07/how-to-use-sqlmetal-exe-to-create-a-class-from-xml-and-database/</guid>
      <description><![CDATA[If you don't have&nbsp;Visual C# Codename Orcas Express Edition installed on your development...]]></description>
      <content:encoded><![CDATA[<p></p> <p>If you don't have&nbsp;<a href="https://msdn.microsoft.com/vstudio/express/future/visualcsharp/default.aspx">Visual C# Codename Orcas Express Edition</a> installed on your development machine, and you are using Visual Studio 2005 with the <a href="https://www.microsoft.com/downloads/details.aspx?FamilyId=1E902C21-340C-4D13-9F04-70EB5E3DCEEA&amp;displaylang=en">LINQ 2006 CTP</a>, then SqlMetal.exe is something that you must lookout for.  <p>It is the O/R mapper that you must use to create a strongly typed class, and use it with DLinq.  <p>You can find SqlMetal.exe at: <em><font color="#008000">%systemdrive%\Program Files\LINQ Preview\Bin</font></em> folder.  <p>Its used as following:  <div><pre class="csharpcode">usage: sqlmetal [options] [<span class="kwrd">&lt;</span><span class="html">input</span> <span class="attr">file</span><span class="kwrd">&gt;</span>]
options:
  /server:<span class="kwrd">&lt;</span><span class="html">name</span><span class="kwrd">&gt;</span>     database server name
  /database:<span class="kwrd">&lt;</span><span class="html">name</span><span class="kwrd">&gt;</span>   database catalog on server
  /user:<span class="kwrd">&lt;</span><span class="html">name</span><span class="kwrd">&gt;</span>       login user id
  /password:<span class="kwrd">&lt;</span><span class="html">name</span><span class="kwrd">&gt;</span>   login password
  /views             extract database views
  /functions         extract database functions
  /sprocs            extract stored procedures
  /xml[:file]        output as xml
  /code[:file]       output as source code
  /map[:file]        generate xml mapping file instead of attributes
  /language:xxx      language for source code (vb,csharp)
  /namespace:<span class="kwrd">&lt;</span><span class="html">name</span><span class="kwrd">&gt;</span>  namespace used for source code
  /pluralize         auto-pluralize table names
  /dataAttributes    auto-generate DataObjectField and Precision attributes
  /timeout:<span class="kwrd">&lt;</span><span class="html">seconds</span><span class="kwrd">&gt;</span> timeout value in seconds to use for database commands

examples:
To generate an XML file with extracted SQL metadata
  sqlmetal /server:myserver /database:northwind /xml:mymeta.xml

To generate an XML file with extracted SQL metadata from an .mdf file
  sqlmetal /xml:mymeta.xml mydbfile.mdf

To generate source code from an XML metadata file
  sqlmetal /namespace:nwind /code:nwind.cs /language:csharp mymetal.xml

To generate source code from SQL metadata directly
  sqlmetal /server:myserver /database:northwind /namespace:nwind /code:nwind.cs /language:csharp

</pre>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>To create an XML file from a database like Northwind, I copied the .mdf as suggested by the above help and pasted it to the same folder. I used the following command:<br><em><font color="#008000">sqlmetal /xml:northwind.xml Northwind.mdf</font></em><br>but it failed with: 
<div><pre class="csharpcode">Unhandled Exception: System.Data.SqlClient.SqlException: An error has occurred while establishing a
connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fac
t that under the default settings SQL Server does not allow remote connections. (provider: SQL Netwo
rk Interfaces, error: 26 - Error Locating Server/Instance Specified)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConne
ction)</pre>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<div>I thought its asking for the server name, so I tried this:<br><em><font color="#008000">sqlmetal /xml:northwind.xml /server:myserver Northwind.mdf</font></em><br>it also failed with the following error: </div>
<div><pre class="csharpcode">Unhandled Exception: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database
 for file Northwind.mdf failed. A database with the same name exists, or specified file cannot be op
ened, or it is located on UNC share.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConne
ction)</pre>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>The command that worked is following:<br><font color="#008000"><em>sqlmetal /server:myserver /database:Northwind /xml:northwind.xml</em> </font></p>
<p>Then I thought of creating a class out of the generated XML. I used the following command and it worked the first time:<br><em><font color="#008000">sqlmetal /code:Northwind.cs /language:csharp Northwind.xml</font></em> 
<p>Creating a class file directly from the database is pretty starightforward, I used the following command:<br><em><font color="#008000">sqlmetal /server:myserver /database:Northwind /code:Northwind.cs /language:csharp</font></em></p>
<p><strong><em><u></u></em></strong>&nbsp;</p>
<p><strong><em><u>C# IDE Support for Visual Studio 2005/C# 2005 Express</u></em></strong></p>
<p>While this preliminary IDE support greatly enhances the editing experience when writing C# 3.0 code in VS 2005, the language service and compiler are still very much in an alpha phase. In the event of a compiler error, many more errors may be reported than are actually present. If you see a large number of errors when building C# 3.0 code, fix the top error in the error list first and build after each fix. 
<p><u><em>Follow these steps to enable LINQ IDE support for Visual Studio 2005 and Visual C# 2005 Express:</em> </u>
<p>First, verify that you are running the release version of Visual Studio 2005 or Visual C# 2005 Express. The language service that will be installed only works with the English version of VS 2005/C# 2005 Express and may cause severe problems if installed on earlier versions. You can verify your version by selecting Help\About in Visual Studio 2005. <br>Shut down any running instances of Visual Studio. <br>Open the \bin folder under the LINQ preview installation directory and run <em><font color="#008000">“Install C# IDE Support”</font></em>. <br>Start VS 2005/C# 2005 Express. </p>
<p><em><u>Follow these steps to restore your original VS 2005/C# 2005 Express language service: </u></em></p>
<p>Shut down any running instances of Visual Studio. <br>Open the \bin folder under the LINQ preview installation directory and run <em><font color="#008000">“Uninstall C# IDE Support”</font></em>. <br>Start VS 2005/C# 2005 Express. 
]]></content:encoded>
    </item>
    <item>
      <title>How To: Seemlessly Export Data From Database to XML using LINQ</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/how-to-seemlessly-export-data-from-database-to-xml-using-linq</link>
      <pubDate>Wed, 06 Jun 2007 07:47:24 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/06/06/how-to-seemlessly-export-data-from-database-to-xml-using-linq/</guid>
      <description><![CDATA[&nbsp; While exploring a number of neat features available in the Visual C# Orcas Express Edition,...]]></description>
      <content:encoded><![CDATA[<p></p> <p>&nbsp;</p> <p>While exploring a number of neat features available in the Visual C# Orcas Express Edition, you will see the following:</p> <p>There is no namespace like DLinq, or XLinq anymore, they are replace with more meaningful<br>System.Data.Linq and<br>System.Xml.Linq </p> <p>However, the latter appears by default in a console application, System.Data.Linq will be added to the references once the O/R mapper a.k.a .dbml file is added. In the express Edition, you can connect to a .mdf, .mdb, or a .sdf(Sql Server Compact Edition) databases.  <p>After instantiating the DataContext class, you will be able to explore its rich features supported with Intellisence.  <p>Apart from that the XML.Linq namespace has got some neat and intuitive features. My favorite is:<br><em>System.Xml.Linq.XElement xlinq = new XElement(XName name, object content); </em> <p>As you would expect from it, any object returning values compatible to IEnumerable is taken care of by the constructor... all by itself.</p> <div class="csharpcode-wrapper" style="width: 70.19%; height: 210px"> <div class="csharpcode"><pre class="alt"><span class="kwrd">using</span> System;</pre><pre><span class="kwrd">using</span> System.Collections.Generic;</pre><pre class="alt"><span class="kwrd">using</span> System.Linq;</pre><pre><span class="kwrd">using</span> System.Text;</pre><pre class="alt"><span class="kwrd">using</span> System.Xml.Linq;</pre><pre>&nbsp;</pre><pre class="alt"><span class="kwrd">namespace</span> ConsoleApplication1</pre><pre>{</pre><pre class="alt">    <span class="kwrd">class</span> Program</pre><pre>    {</pre><pre class="alt">        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre><pre>        {</pre><pre class="alt">            NorthwindDataContext north = <span class="kwrd">new</span> NorthwindDataContext();</pre><pre>            <span class="rem">//sample query, not related to this demo!!</span></pre><pre class="alt">            var products = from p <span class="kwrd">in</span> north.Products</pre><pre>                           <span class="kwrd">where</span> p.ProductID &gt; 10 &amp;&amp; p.ProductID &lt; 200</pre><pre class="alt">                           select <span class="kwrd">new</span>{</pre><pre>                                      p.ProductName,</pre><pre class="alt">                                      p.UnitPrice</pre><pre>                                  };</pre><pre class="alt">            <span class="rem">//the actual thing!!!</span></pre><pre>            System.Xml.Linq.XElement xlinq = <span class="kwrd">new</span> XElement(<span class="str">"Products"</span>,</pre><pre class="alt">                                             from p <span class="kwrd">in</span> north.Products</pre><pre>                                             <span class="kwrd">where</span> p.ProductName.StartsWith(<span class="str">"S"</span>)</pre><pre class="alt">                                             select <span class="kwrd">new</span> XElement(<span class="str">"Product"</span>, <span class="kwrd">new</span> XAttribute(<span class="str">"UnitPrice"</span>, p.UnitPrice),</pre><pre>                                                    <span class="kwrd">new</span> XAttribute(<span class="str">"QuantityPerUnit"</span>, p.QuantityPerUnit), </pre><pre class="alt">                                                        <span class="kwrd">new</span> XElement(<span class="str">"ProductName"</span>, p.ProductName),</pre><pre>                                                    <span class="kwrd">new</span> XElement(<span class="str">"SupplierName"</span>, p.Supplier.CompanyName)</pre><pre class="alt">                                                        )</pre><pre>                                             );</pre><pre class="alt">            xlinq.Save(<span class="str">"NewXML.xml"</span>);</pre><pre>            Console.Write(xlinq);            </pre><pre class="alt">            Console.Read();</pre><pre>        }</pre><pre class="alt">    }    </pre><pre>}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>The output in the (command window) looks like the following:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/HowToSeemlesslyExportDataFromDatabasetoX_42E0/Output-linq%5B3%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/HowToSeemlesslyExportDataFromDatabasetoX_42E0/Output-linq%5B3%5D.jpg" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="616" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/HowToSeemlesslyExportDataFromDatabasetoX_42E0/Output-linq_thumb%5B1%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/HowToSeemlesslyExportDataFromDatabasetoX_42E0/Output-linq_thumb%5B1%5D.jpg" width="699" border="0"></a> </p>
<p>Check out this space, lots more coming up...</p>
<p>Microsoft ROCKS!!!</p>]]></content:encoded>
    </item>
    <item>
      <title>LINQ Lists - Anonymous Methods and Lambda Expressions</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/linq-lists-anonymous-methods-and-lambda-expressions</link>
      <pubDate>Wed, 06 Jun 2007 07:22:36 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/06/06/linq-lists-anonymous-methods-and-lambda-expressions/</guid>
      <description><![CDATA[&nbsp; Year: 2005 A.D.The C# 2.0 specification is released in the month of September. It talks about...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p><em><strong>Year: 2005 A.D.</strong><br></em>The C# 2.0 specification is released in the month of September. It talks about "new" features. We were introduced with a new "in-line" feature of using delegates. We called it "Anonymous Methods". Needless to say, its named as such because:<br>- Its Anonymous (no method name is given)<br>- Its InLine (How can you call something without a name, makes sense doesn't it?)  <p><strong><em>Year: 2006 A.D.</em><br></strong>The C# 3.0 specification is released in the month of May. It talks about new features. Among a number of path breaking innovative ideas, we have something called "Lambda Expressions". It claims to provide more concise, functional syntax for writing anonymous methods.  <p>Lets checkout the basic syntax of Anonymous Methods:</p> <div class="csharpcode-wrapper" style="width: 78.7%; height: 210px"> <div class="csharpcode"><pre class="alt"><span class="kwrd">delegate</span> <span class="kwrd">void</span> D(<span class="kwrd">int</span> x); </pre><pre>D d1 = <span class="kwrd">delegate</span> { }; <span class="rem">// Ok </span></pre><pre class="alt">D d2 = <span class="kwrd">delegate</span>() { }; <span class="rem">// Error, signature mismatch </span></pre><pre>D d3 = <span class="kwrd">delegate</span>(<span class="kwrd">long</span> x) { }; <span class="rem">// Error, signature mismatch </span></pre><pre class="alt">D d4 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span> x) { }; <span class="rem">// Ok </span></pre><pre>D d5 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span> x) { <span class="kwrd">return</span>; }; <span class="rem">// Ok </span></pre><pre class="alt">D d6 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span> x) { <span class="kwrd">return</span> x; }; <span class="rem">// Error, return type mismatch </span></pre><pre><span class="kwrd">delegate</span> <span class="kwrd">void</span> E(<span class="kwrd">out</span> <span class="kwrd">int</span> x); </pre><pre class="alt">E e1 = <span class="kwrd">delegate</span> { }; <span class="rem">// Error, E has an out parameter </span></pre><pre>E e2 = <span class="kwrd">delegate</span>(<span class="kwrd">out</span> <span class="kwrd">int</span> x) { x = 1; }; <span class="rem">// Ok </span></pre><pre class="alt">E e3 = <span class="kwrd">delegate</span>(<span class="kwrd">ref</span> <span class="kwrd">int</span> x) { x = 1; }; <span class="rem">// Error, signature mismatch </span></pre><pre><span class="kwrd">delegate</span> <span class="kwrd">int</span> P(<span class="kwrd">params</span> <span class="kwrd">int</span>[] a);</pre><pre class="alt">P p1 = <span class="kwrd">delegate</span> { }; <span class="rem">// Error, end of block reachable </span></pre><pre>P p2 = <span class="kwrd">delegate</span> { <span class="kwrd">return</span>; }; <span class="rem">// Error, return type mismatch </span></pre><pre class="alt">P p3 = <span class="kwrd">delegate</span> { <span class="kwrd">return</span> 1; }; <span class="rem">// Ok </span></pre><pre>P p4 = <span class="kwrd">delegate</span> { <span class="kwrd">return</span> <span class="str">"Hello"</span>; }; <span class="rem">// Error, return type mismatch </span></pre><pre class="alt">P p5 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span>[] a) { <span class="rem">// Ok </span></pre><pre><span class="kwrd">return</span> a[0]; }; </pre><pre class="alt">P p6 = <span class="kwrd">delegate</span>(<span class="kwrd">params</span> <span class="kwrd">int</span>[] a) { <span class="rem">// Error, params modifier </span></pre><pre><span class="kwrd">return</span> a[0]; }; </pre><pre class="alt">P p7 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span>[] a) { <span class="rem">// Error, return type mismatch </span></pre><pre><span class="kwrd">if</span> (a.Length &gt; 0) </pre><pre class="alt"><span class="kwrd">return</span> a[0]; </pre><pre><span class="kwrd">return</span> <span class="str">"Hello"</span>; </pre><pre class="alt">}; </pre><pre><span class="kwrd">delegate</span> <span class="kwrd">object</span> Q(<span class="kwrd">params</span> <span class="kwrd">int</span>[] a); </pre><pre class="alt">Q q1 = <span class="kwrd">delegate</span>(<span class="kwrd">int</span>[] a) { <span class="rem">// Ok </span></pre><pre><span class="kwrd">if</span> (a.Length &gt; 0) </pre><pre class="alt"><span class="kwrd">return</span> a[0]; </pre><pre><span class="kwrd">return</span> <span class="str">"Hello"</span>; </pre><pre class="alt">};</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>The best example of an anonymous method is when a delegate is used as an Event Handler:</p>
<p>Without Anonymous:</p>
<div class="csharpcode-wrapper" style="width: 78.96%; height: 127px">
<div class="csharpcode"><pre class="alt">MyButton.Click += <span class="kwrd">new</span> EventHandler(MyButtonClicked);</pre><pre><span class="kwrd">void</span> MyButtonClicked(<span class="kwrd">object</span> sender, EventArgs e)</pre><pre class="alt">{</pre><pre>MessageBox.Show(<span class="str">"Hello World!"</span>);</pre><pre class="alt">}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>With Anonymous:</p>
<div class="csharpcode-wrapper" style="width: 79.06%; height: 97px">
<div class="csharpcode"><pre class="alt">MyButton.Click += <span class="kwrd">delegate</span>{</pre><pre>MessageBox.Show(<span class="str">"Hello World!"</span>);</pre><pre class="alt">}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>From the above comparison, you can make out that using InLine Functions, we do not need to:<br>- pass arguments across functions.<br>- you can use the scope level variables easily.<br>But, it has tradeoffs which involve code readability and reusability hassles. As the age old saying goes about InLine Functions: Use it efficiently, as its faster than calling functions but slightly difficult to manage.</p>
<p><em><u><strong>Lambda Expressions</strong></u></em></p>
<p>It is written as a parameter list, followed by the =&gt; (slanted lambda?) token, followed by an expression or a statement block.</p>
<div class="csharpcode-wrapper" style="width: 79.42%; height: 400px">
<div class="csharpcode"><pre class="alt"><span class="kwrd">class</span> Program</pre><pre>{</pre><pre class="alt">    <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre><pre>    {</pre><pre class="alt">        List&lt;Vehicle&gt; vlist = <span class="kwrd">new</span> List&lt;Vehicle&gt;</pre><pre>                              {</pre><pre class="alt">                                  <span class="kwrd">new</span> Vehicle{Make=<span class="str">"Mercedes"</span>, Model=<span class="str">"Benz"</span>, Mileage=12},</pre><pre>                                  <span class="kwrd">new</span> Vehicle{Make=<span class="str">"Renault"</span>, Model=<span class="str">"Logan"</span>, Mileage=15},</pre><pre class="alt">                                  <span class="kwrd">new</span> Vehicle{Make=<span class="str">"Honda"</span>, Model=<span class="str">"Accord"</span>, Mileage=12},</pre><pre>                              };</pre><pre class="alt">        IEnumerable&lt;Vehicle&gt; vehicles = vlist.Where(v =&gt; v.Mileage &gt; 10);</pre><pre>        <span class="kwrd">foreach</span> (Vehicle v <span class="kwrd">in</span> vehicles)</pre><pre class="alt">        {</pre><pre>            Console.WriteLine(v.Make);</pre><pre class="alt">            Console.WriteLine(v.Model);</pre><pre>            Console.WriteLine(v.Mileage);</pre><pre class="alt">            Console.WriteLine(<span class="str">"-----------------"</span>);</pre><pre>        }</pre><pre class="alt">        Console.Read();</pre><pre>    }</pre><pre class="alt">}</pre><pre>&nbsp;</pre><pre class="alt"><span class="kwrd">public</span> <span class="kwrd">class</span> Vehicle</pre><pre>{</pre><pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">string</span> Make;</pre><pre>    <span class="kwrd">public</span> <span class="kwrd">string</span> Model;</pre><pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">int</span> Mileage;</pre><pre>}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>In the above example:<br><em>IEnumerable&lt;Vehicle&gt; vehicles = vlist.Where(v =&gt; v.Mileage &gt; 10);</em></p><em>
<p></em>The Lambda Expression: <br><em>v =&gt; v.Mileage &gt; 10 </em></p>
<p>replaces: <br><em>new delegate(Vehicle v){<br>v.Mileage &gt; 10;<br>}</em></p>
<p>It can also be replaced by:</p>
<div class="csharpcode-wrapper" style="width: 79.29%; height: 104px">
<div class="csharpcode"><pre class="alt">IEnumerable&lt;Vehicle&gt; vehicles = from v <span class="kwrd">in</span> vlist</pre><pre>                                            <span class="kwrd">where</span> v.Mileage &gt; 12</pre><pre class="alt">                                            select v;</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>Try this: <a href="https://msdn.microsoft.com/msdnmag/issues/07/06/CSharp30/default.aspx">The Evolution Of LINQ And Its Impact On The Design Of C#</a></p>
<p>These samples were created using: <a href="https://msdn.microsoft.com/vstudio/express/future/visualcsharp/default.aspx">Microsoft Visual C# Codename "Orcas" Express Edition</a></p>]]></content:encoded>
    </item>
    <item>
      <title>The Var Of The Worlds</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/the-var-of-the-worlds</link>
      <pubDate>Wed, 06 Jun 2007 01:30:23 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/06/06/the-var-of-the-worlds/</guid>
      <description><![CDATA[Hello folks,  This time we will explore LINQ over a series of Posts.  As you must be knowing the...]]></description>
      <content:encoded><![CDATA[<p></p> <p>Hello folks,  <p>This time we will explore LINQ over a series of Posts.  <p>As you must be knowing the age old "var" is back. But, is it the same old var that used to be in VB 6.0 days?  <p>Precisely its not the same it has got a number of new features:<br>- You have to declare and instantiate it at the same line of code. Reason: It is smart enough to understand the assigned data type, and it becomes it.<br><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-declare%5B4%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-declare%5B4%5D.jpg" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="251" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-declare_thumb%5B2%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-declare_thumb%5B2%5D.jpg" width="471" border="0"></a>&nbsp;<br>var s = int.MaxValue; // it becomes Int32<br>var s2 = double.MaxValue; // it becomes double<br>var s3 = "The Var Of The Worlds" // string </p> <p>- You cannot assign multiple data types to it. Any attempt to do so results in a compile time error.<br><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-typecast%5B7%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-typecast%5B7%5D.jpg" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="227" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-typecast_thumb%5B5%5D.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/TheVarOfTheWorlds_13BC8/var-typecast_thumb%5B5%5D.jpg" width="456" border="0"></a>  <p>Code with var:</p> <div class="csharpcode-wrapper" style="width: 62.08%; height: 210px"> <div class="csharpcode"><pre class="alt"><span class="lnum">   1:</span> <span class="kwrd">class</span> Program</pre><pre><span class="lnum">   2:</span> {</pre><pre class="alt"><span class="lnum">   3:</span>     <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre><pre><span class="lnum">   4:</span>     {</pre><pre class="alt"><span class="lnum">   5:</span>         var s = from m <span class="kwrd">in</span> <span class="kwrd">typeof</span>(<span class="kwrd">string</span>).GetMethods()</pre><pre><span class="lnum">   6:</span>                 select m.Name;</pre><pre class="alt"><span class="lnum">   7:</span>         <span class="kwrd">foreach</span>(<span class="kwrd">string</span> str <span class="kwrd">in</span> s)</pre><pre><span class="lnum">   8:</span>         {</pre><pre class="alt"><span class="lnum">   9:</span>             Console.WriteLine(str);</pre><pre><span class="lnum">  10:</span>         }</pre><pre class="alt"><span class="lnum">  11:</span>         Console.Read();</pre><pre><span class="lnum">  12:</span>     }</pre><pre class="alt"><span class="lnum">  13:</span> }</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p>Code without a var:</p>
<div class="csharpcode-wrapper" style="width: 62.16%; height: 231px">
<div class="csharpcode"><pre class="alt"><span class="lnum">   1:</span> <span class="kwrd">class</span> Program</pre><pre><span class="lnum">   2:</span> {</pre><pre class="alt"><span class="lnum">   3:</span>     <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)</pre><pre><span class="lnum">   4:</span>     {</pre><pre class="alt"><span class="lnum">   5:</span>         IEnumerable&lt;<span class="kwrd">string</span>&gt; s  = </pre><pre><span class="lnum">   6:</span>             from m <span class="kwrd">in</span> <span class="kwrd">typeof</span>(<span class="kwrd">string</span>).GetMethods()</pre><pre class="alt"><span class="lnum">   7:</span>             select m.Name;</pre><pre><span class="lnum">   8:</span> &nbsp;</pre><pre class="alt"><span class="lnum">   9:</span>         <span class="kwrd">foreach</span>(<span class="kwrd">string</span> str <span class="kwrd">in</span> s)</pre><pre><span class="lnum">  10:</span>         {</pre><pre class="alt"><span class="lnum">  11:</span>             Console.WriteLine(str);</pre><pre><span class="lnum">  12:</span>         }</pre><pre class="alt"><span class="lnum">  13:</span>         Console.Read();</pre><pre><span class="lnum">  14:</span>     }</pre><pre class="alt"><span class="lnum">  15:</span> }</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>]]></content:encoded>
    </item>
    <item>
      <title>How To: Create an efficient data driven page with Business Objects, GridView, Custom paging, and AJAX</title>
      <link>https://docs.microsoft.com/archive/blogs/sanjeets/how-to-create-an-efficient-data-driven-page-with-business-objects-gridview-custom-paging-and-ajax</link>
      <pubDate>Sat, 02 Jun 2007 08:53:49 GMT</pubDate>
      <dc:creator><![CDATA[MSDN Archive]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sanjeets/2007/06/02/how-to-create-an-efficient-data-driven-page-with-business-objects-gridview-custom-paging-and-ajax/</guid>
      <description><![CDATA[Preface: I have seen a large number of cases where the customer complaint of performance and...]]></description>
      <content:encoded><![CDATA[<p><font face="Segoe UI" size="2"><u><strong>Preface:</strong></u></font></p> <div><font face="Segoe UI" size="2">I have seen a large number of cases where the customer complaint of performance and scalability issues <br>when they create/manage a data-aware application. That’s when I decided that I should come up with <br>something that is concise, efficient, and easy to implement for developers. <br>Here, is what I created a couple of days ago. </font></div> <p><font face="Segoe UI" size="2">GridView is awesome, and if you combine it with Sql Server 2005, DetailsView and FormView <br>you have a formidable force to build a rich data aware page. You can achieve almost everything <br>that you may require on a page without even writing a single line of code in your ASPX, <br>even Custom paging (it requires you to write some views in TSQL).</font>  <p><font face="Segoe UI" size="2"></font></p> <p><font face="Segoe UI" size="2"><strong><u>Requirement Analysis:</u></strong></font></p> <ol> <li><font face="Segoe UI" size="2">A simple page for that has to fetch a large amount of data (more than 10K rows) from a remote database.</font>  <li><font face="Segoe UI" size="2">I need paging and&nbsp;sorting support with CRUD on the page</font>  <li><font face="Segoe UI" size="2">I need a way to customize the GridView control</font>  <li><font face="Segoe UI" size="2">I need to use a 3-tier structure where I have Data Access Layer, Business Access Layer, and the Presentation Layer.</font>  <li><font face="Segoe UI" size="2">Everybody is talking and using AJAX, so I need that also. I like the word <em>"Partial-Rendering"</em> ;)</font></li></ol> <p><font face="Segoe UI" size="2"><u><strong>Prerequisites:</strong></u></font></p> <p><font face="Segoe UI" size="2"></font></p> <p><font face="Segoe UI" size="2">You need Visual Studio 2005, Sql Server 2005, and ASP.net AJAX 1.0</font>  <p><font face="Segoe UI" size="2"><u><strong>Architecture:</strong></u></font></p> <p><font face="Segoe UI" size="2"><strong><u>The DAL:</u></strong></font></p> <p><font face="Segoe UI" size="2">It is implemented using a Dataset. This is a strongly typed dataset, and contains all the required Stored procedures and queries.</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/xsd2.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/xsd2.jpg" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/xsd_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/xsd_thumb.jpg" width="578" border="0"></a> </p> <p><font face="Segoe UI" size="2">We will concentrate on the class "Entity" only.</font></p> <p><font face="Segoe UI" size="2">The following is the implementation of the BAL.</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/cd12.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/cd12.jpg" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="467" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/cd_thumb8.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/cd_thumb8.jpg" width="640" border="0"></a> </p> <p><font face="Segoe UI" size="2">The presentation layer has only 1 page for now. I hope this is what we need now. It looks like the following:</font></p> <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/UI6.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/UI6.jpg" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="509" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/UI_thumb2.jpg" original-url="https://blogs.msdn.com/blogfiles/sanjeets/WindowsLiveWriter/UsingBusinessObjectsandlargeda.0GridView_2127/UI_thumb2.jpg" width="800" border="0"></a> </p> <p><font face="Segoe UI" size="2">As we can see, we have highly </font><font face="Segoe UI" size="2">Customized the datagrid. Lets dive deeper into the functionality.</font></p> <p><font face="Segoe UI" size="2"><strong><u>The BAL:</u></strong></font></p> <p><font face="Segoe UI" size="2">The following code snippet contains Insert, Edit, and Delete functions required to do usual stuff. Its self explanatory.</font></p> <div class="csharpcode-wrapper" style="width: 46.49%; height: 200px"> <div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This is the Insert function for the class. </span></pre><pre class="alt"><span class="rem">/// It takes all the columns as arguments and uses a DatabaseDirect mode to update the database directly.</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="EntityID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="Title"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="Description"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre><span class="kwrd">public</span> <span class="kwrd">int</span> Insert(<span class="kwrd">int</span> EntityID, <span class="kwrd">string</span> UserID, <span class="kwrd">string</span> Title, <span class="kwrd">string</span> Description)</pre><pre class="alt">{</pre><pre>    <span class="kwrd">int</span> rowsAffected = 0;</pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre>        <span class="rem">//Update the DB directly</span></pre><pre class="alt">        <span class="rem">//Insert function is defined in the DataSet</span></pre><pre>        rowsAffected = ad.Insert(UserID, Title, Description);</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="rem">//throw all the error that are catched here</span></pre><pre class="alt">        <span class="kwrd">throw</span>;</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">return</span> rowsAffected;</pre><pre>}</pre><pre class="alt">&nbsp;</pre><pre><span class="rem">/// &lt;summary&gt;</span></pre><pre class="alt"><span class="rem">/// This is the Edit function for the class. </span></pre><pre><span class="rem">/// It takes all the columns as arguments and uses a DatabaseDirect mode to update the database directly.</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="rem">/// &lt;param name="EntityID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="Title"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="Description"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre class="alt"><span class="kwrd">public</span> <span class="kwrd">int</span> Edit(<span class="kwrd">int</span> EntityID, <span class="kwrd">string</span> UserID, <span class="kwrd">string</span> Title, <span class="kwrd">string</span> Description)</pre><pre>{</pre><pre class="alt">    <span class="kwrd">int</span> rowsAffected = 0;</pre><pre>    <span class="kwrd">try</span></pre><pre class="alt">    {</pre><pre>        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre class="alt">        <span class="rem">//Update function is defined in the DataSet</span></pre><pre>        rowsAffected = ad.Update(UserID, Title, Description, EntityID, EntityID);</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="rem">//throw all the error that are catched here</span></pre><pre class="alt">        <span class="kwrd">throw</span>;</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">return</span> rowsAffected;</pre><pre>}</pre><pre class="alt">&nbsp;</pre><pre><span class="rem">/// &lt;summary&gt;</span></pre><pre class="alt"><span class="rem">/// This is the Delete function for the class. </span></pre><pre><span class="rem">/// It takes all the columns as arguments and uses a DatabaseDirect mode to update the database directly.</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="rem">/// &lt;param name="EntityID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre><span class="kwrd">public</span> <span class="kwrd">int</span> Delete(<span class="kwrd">int</span> EntityID)</pre><pre class="alt">{</pre><pre>    <span class="kwrd">int</span> rowsAffected = 0;</pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre>        <span class="rem">//Delete function is defined in the DataSet</span></pre><pre class="alt">        rowsAffected = ad.Delete(EntityID);</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">catch</span></pre><pre>    {</pre><pre class="alt">        <span class="rem">//throw all the error that are catched here or apply</span></pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">return</span> rowsAffected;</pre><pre class="alt">}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p><font face="Segoe UI" size="2">Now the Select functions. These functions are the key to our demo. We will explain each of them at a later part in this post.</font></p>
<div class="csharpcode-wrapper" style="width: 46.59%; height: 177px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This function selects all the records filtered by UserID</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre><span class="kwrd">public</span> ManageabilityDS.EntityDataTable Select(<span class="kwrd">string</span> UserID)</pre><pre class="alt">{</pre><pre>    <span class="kwrd">try</span></pre><pre class="alt">    {</pre><pre>        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre class="alt">        <span class="rem">//GetEntitiesByUser function is defined in the DataSet</span></pre><pre>        <span class="kwrd">return</span> ad.GetEntitiesByUser(UserID);</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>}</pre><pre class="alt">&nbsp;</pre><pre><span class="rem">/// &lt;summary&gt;</span></pre><pre class="alt"><span class="rem">/// This function selects all the records filtered by UserID and EntityID</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="EntityID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre><span class="kwrd">public</span> ManageabilityDS.EntityDataTable Select(<span class="kwrd">string</span> UserID, <span class="kwrd">int</span> EntityID)</pre><pre class="alt">{</pre><pre>    <span class="kwrd">try</span></pre><pre class="alt">    {</pre><pre>        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre class="alt">        <span class="rem">//GetEntityByUserAndEntityID function is defined in the DataSet</span></pre><pre>        <span class="kwrd">return</span> ad.GetEntityByUserAndEntityID(UserID, EntityID);</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>}   </pre><pre class="alt">&nbsp;</pre><pre><span class="rem">/// &lt;summary&gt;</span></pre><pre class="alt"><span class="rem">/// This function gets the maximum rows from the table after its sequenced using Row_number</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre class="alt"><span class="kwrd">public</span> <span class="kwrd">long</span> GetMaxNumberOfRows(<span class="kwrd">string</span> UserID)</pre><pre>{</pre><pre class="alt">    <span class="kwrd">long</span> num = 0;</pre><pre>    <span class="kwrd">try</span></pre><pre class="alt">    {</pre><pre>        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre class="alt">        <span class="rem">//GetNumberOfRows function is defined in the DataSet</span></pre><pre>        num = (<span class="kwrd">long</span>)ad.GetNumberOfRows(UserID);</pre><pre class="alt">        <span class="kwrd">return</span> num;</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">catch</span></pre><pre>    {</pre><pre class="alt">        <span class="kwrd">throw</span>;</pre><pre>    }</pre><pre class="alt">}</pre><pre>&nbsp;</pre><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This function return a strongly type list containing paged data</span></pre><pre class="alt"><span class="rem">/// A benefit of using Generic here is to minimize the size of the object</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="StartRowIndex"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="MaximumRows"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre class="alt"><span class="kwrd">public</span> List&lt;Entity&gt; Select(<span class="kwrd">string</span> UserID, <span class="kwrd">int</span> StartRowIndex, <span class="kwrd">int</span> MaximumRows)</pre><pre>{</pre><pre class="alt">    ManageabilityDS.EntityDataTable tbl = <span class="kwrd">null</span>;</pre><pre>    List&lt;Entity&gt; t = <span class="kwrd">new</span> List&lt;Entity&gt;(); </pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre>        <span class="rem">//GetPagedEntityByUser function is defined in the DataSet</span></pre><pre class="alt">        tbl = ad.GetPagedEntityByUser(StartRowIndex, MaximumRows, UserID);</pre><pre>        <span class="rem">//fill the strongly typed List with data</span></pre><pre class="alt">        <span class="kwrd">foreach</span> (ManageabilityDS.EntityRow row <span class="kwrd">in</span> tbl.Rows)</pre><pre>        {</pre><pre class="alt">            Entity en = <span class="kwrd">new</span> Entity();</pre><pre>            en.EntityID = row.EntityID;</pre><pre class="alt">            en.UserId = row.UserID;</pre><pre>            en.Title = row.Title;</pre><pre class="alt">            en.Description = row.Description;</pre><pre>            t.Add(en);</pre><pre class="alt">        }</pre><pre>        <span class="kwrd">return</span> t;</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>}</pre><pre class="alt">&nbsp;</pre><pre><span class="rem">/// &lt;summary&gt;</span></pre><pre class="alt"><span class="rem">/// This function return a strongly type list containing paged and sorted data</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="StartRowIndex"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="MaximumRows"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="ColumnToOrder"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="OrderDirection"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre class="alt"><span class="kwrd">public</span> List&lt;Entity&gt; Select(<span class="kwrd">string</span> UserID, <span class="kwrd">int</span> StartRowIndex, <span class="kwrd">int</span> MaximumRows, <span class="kwrd">string</span> ColumnToOrder, <span class="kwrd">string</span> OrderDirection)</pre><pre>{</pre><pre class="alt">    ManageabilityDS.EntityDataTable tbl = <span class="kwrd">null</span>;</pre><pre>    List&lt;Entity&gt; t = <span class="kwrd">new</span> List&lt;Entity&gt;();</pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre>        <span class="rem">//GetPagedEntityByUserOrdered function is defined in the DataSet</span></pre><pre class="alt">        tbl = ad.GetPagedEntityByUserOrdered(StartRowIndex, MaximumRows, UserID, ColumnToOrder, OrderDirection);</pre><pre>        <span class="rem">//fill the strongly typed List with data</span></pre><pre class="alt">        <span class="kwrd">foreach</span> (ManageabilityDS.EntityRow row <span class="kwrd">in</span> tbl.Rows)</pre><pre>        {</pre><pre class="alt">            Entity en = <span class="kwrd">new</span> Entity();</pre><pre>            en.EntityID = row.EntityID;</pre><pre class="alt">            en.UserId = row.UserID;</pre><pre>            en.Title = row.Title;</pre><pre class="alt">            en.Description = row.Description;</pre><pre>            t.Add(en);</pre><pre class="alt">        }</pre><pre>        <span class="kwrd">return</span> t;</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>}</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p><font face="Segoe UI" size="2"><u><strong></strong></u></font>&nbsp;</p>
<p><font face="Segoe UI" size="2"><u><strong>The Presentation Layer:</strong></u></font></p>
<p><font face="Segoe UI" size="2">The datag</font><font face="Segoe UI" size="2">rid looks like following in code:</font></p>
<div class="csharpcode-wrapper" style="width: 47%; height: 190px">
<div class="csharpcode"><pre class="alt">&lt;asp:GridView ID=<span class="str">"MainGrid"</span> runat=<span class="str">"server"</span> EnableViewState=<span class="str">"true"</span> AutoGenerateColumns=<span class="str">"False"</span></pre><pre>    CellPadding=<span class="str">"4"</span> ForeColor=<span class="str">"#333333"</span> Width=<span class="str">"100%"</span> PageSize=<span class="str">"2"</span> DataKeyNames=<span class="str">"EntityID"</span></pre><pre class="alt">    EmptyDataText=<span class="str">"No data available"</span> OnRowDeleting=<span class="str">"MainGrid_RowDeleting"</span>&gt;</pre><pre>    &lt;FooterStyle BackColor=<span class="str">"#507CD1"</span> Font-Bold=<span class="str">"True"</span> ForeColor=<span class="str">"White"</span> /&gt;</pre><pre class="alt">    &lt;RowStyle BackColor=<span class="str">"#EFF3FB"</span> /&gt;</pre><pre>    &lt;EditRowStyle BackColor=<span class="str">"#2461BF"</span> /&gt;</pre><pre class="alt">    &lt;SelectedRowStyle BackColor=<span class="str">"#D1DDF1"</span> Font-Bold=<span class="str">"True"</span> ForeColor=<span class="str">"#333333"</span> /&gt;</pre><pre>    &lt;HeaderStyle Font-Bold=<span class="str">"True"</span> HorizontalAlign=<span class="str">"Left"</span> /&gt;</pre><pre class="alt">    &lt;AlternatingRowStyle BackColor=<span class="str">"White"</span> /&gt;</pre><pre>    &lt;Columns&gt;</pre><pre class="alt">        &lt;asp:TemplateField HeaderText=<span class="str">"Details"</span>&gt;</pre><pre>            &lt;HeaderStyle Font-Bold=<span class="str">"True"</span> Width=<span class="str">"80%"</span> /&gt;</pre><pre class="alt">            &lt;ItemTemplate&gt;</pre><pre>                &lt;table width=<span class="str">"100%"</span>&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td width=<span class="str">"15%"</span>&gt;</pre><pre class="alt">                            &lt;span&gt;&lt;b&gt;ID:&lt;/b&gt;&lt;/span&gt;</pre><pre>                        &lt;/td&gt;</pre><pre class="alt">                        &lt;td&gt;</pre><pre>                            &lt;asp:Label ID=<span class="str">"EntityIDLabel"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%#Bind("EntityID")%&gt;'</span>&gt;&lt;/asp:Label&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td bgcolor=<span class="str">"silver"</span> colspan=<span class="str">"2"</span>&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td&gt;</pre><pre class="alt">                            &lt;span&gt;&lt;b&gt;Title:&lt;/b&gt;&lt;/span&gt;</pre><pre>                        &lt;/td&gt;</pre><pre class="alt">                        &lt;td&gt;</pre><pre>                            &lt;asp:Label ID=<span class="str">"TitleLabel"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%#Bind("Title")%&gt;'</span>&gt;&lt;/asp:Label&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td bgcolor=<span class="str">"silver"</span> colspan=<span class="str">"2"</span>&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td&gt;</pre><pre class="alt">                            &lt;span&gt;&lt;b&gt;Description:&lt;/b&gt;&lt;/span&gt;</pre><pre>                        &lt;/td&gt;</pre><pre class="alt">                        &lt;td&gt;</pre><pre>                            &lt;asp:Label ID=<span class="str">"DescriptionLabel"</span> runat=<span class="str">"server"</span> Font-Italic=<span class="str">"true"</span> Text=<span class="str">'&lt;%#Bind("Description")%&gt;'</span>&gt;&lt;/asp:Label&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                &lt;/table&gt;</pre><pre>            &lt;/ItemTemplate&gt;</pre><pre class="alt">        &lt;/asp:TemplateField&gt;</pre><pre>        &lt;asp:TemplateField HeaderText=<span class="str">"Options"</span>&gt;</pre><pre class="alt">            &lt;ItemTemplate&gt;</pre><pre>                &lt;table width=<span class="str">"100%"</span>&gt;</pre><pre class="alt">                    &lt;tr&gt;</pre><pre>                        &lt;td valign=<span class="str">"top"</span>&gt;</pre><pre class="alt">                            &lt;asp:LinkButton ID=<span class="str">"Select"</span> CommandName=<span class="str">"Select"</span> runat=<span class="str">"server"</span> Text=<span class="str">"Select"</span>&gt;&lt;/asp:LinkButton&gt;</pre><pre>                        &lt;/td&gt;</pre><pre class="alt">                    &lt;/tr&gt;</pre><pre>                    &lt;tr&gt;</pre><pre class="alt">                        &lt;td valign=<span class="str">"top"</span>&gt;</pre><pre>                            &lt;asp:LinkButton ID=<span class="str">"Delete"</span> CommandName=<span class="str">"Delete"</span> runat=<span class="str">"server"</span> Text=<span class="str">"Delete"</span> OnClientClick=<span class="str">"return confirm('Are you sure you want to delete this record?');"</span>&gt;&lt;/asp:LinkButton&gt;</pre><pre class="alt">                        &lt;/td&gt;</pre><pre>                    &lt;/tr&gt;</pre><pre class="alt">                &lt;/table&gt;</pre><pre>            &lt;/ItemTemplate&gt;</pre><pre class="alt">            &lt;HeaderStyle Font-Bold=<span class="str">"False"</span> /&gt;</pre><pre>        &lt;/asp:TemplateField&gt;</pre><pre class="alt">    &lt;/Columns&gt;</pre><pre>&lt;/asp:GridView&gt;</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p><font face="Segoe UI" size="2">We have made extensive use of template columns to give it a different look. <br>To bind the data we simply used: <em>Text='&lt;%#Bind("Column_Name")%&gt;'</em> e.g.<br><em>Text = '&lt;%#Bind("Title")%&gt;'</em></font></p>
<p><font face="Segoe UI" size="2">Notice that the paging is disabled. DataKeyNames is set to the Primary Key,</font><font face="Segoe UI" size="2"><br>and we have defined OnRowDeleting event for deleting a record.</font></p>
<p><font face="Segoe UI" size="2">Remember those days, when we used to code OnItemDatBound event in <br>ASP.Net 1.1 to bind the Delete button attribute with an OnClick event. Now, <br>its as easy as assigning <em>OnClientClick = [required javascript]</em> e.g.<br><em>OnClientClick = "return confirm(Are you sure?)"</em></font>&nbsp;</p>
<p><font face="Segoe UI" size="2">The DetailsView looks like the following in code:</font></p>
<div class="csharpcode-wrapper" style="width: 46.9%; height: 170px">
<div class="csharpcode"><pre class="alt">&lt;asp:DetailsView ID=<span class="str">"EntityDetailsView"</span> runat=<span class="str">"server"</span> AutoGenerateRows=<span class="str">"False"</span> DataKeyNames=<span class="str">"EntityID"</span></pre><pre>    DataSourceID=<span class="str">"odsDetailView"</span> Height=<span class="str">"50px"</span> Width=<span class="str">"100%"</span> OnItemInserted=<span class="str">"EntityDetailsView_ItemInserted"</span></pre><pre class="alt">    OnItemUpdated=<span class="str">"EntityDetailsView_ItemUpdated"</span>&gt;</pre><pre>    &lt;Fields&gt;</pre><pre class="alt">        &lt;asp:BoundField DataField=<span class="str">"EntityID"</span> HeaderText=<span class="str">"ID:"</span> InsertVisible=<span class="str">"False"</span> ReadOnly=<span class="str">"True"</span></pre><pre>            SortExpression=<span class="str">"EntityID"</span> HeaderStyle-Width=<span class="str">"15%"</span> HeaderStyle-Font-Bold=<span class="str">"true"</span> /&gt;</pre><pre class="alt">        &lt;asp:BoundField DataField=<span class="str">"UserID"</span> HeaderText=<span class="str">"UserID"</span> SortExpression=<span class="str">"UserID"</span> Visible=<span class="str">"False"</span> /&gt;</pre><pre>        &lt;asp:TemplateField HeaderText=<span class="str">"Title:"</span> HeaderStyle-VerticalAlign=<span class="str">"Top"</span> SortExpression=<span class="str">"Title"</span></pre><pre class="alt">            HeaderStyle-Font-Bold=<span class="str">"true"</span>&gt;</pre><pre>            &lt;EditItemTemplate&gt;</pre><pre class="alt">                &lt;asp:TextBox ID=<span class="str">"TextBox1"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Title") %&gt;'</span> CssClass=<span class="str">"textbox"</span>&gt;&lt;/asp:TextBox&gt;</pre><pre>            &lt;/EditItemTemplate&gt;</pre><pre class="alt">            &lt;InsertItemTemplate&gt;</pre><pre>                &lt;asp:TextBox ID=<span class="str">"TextBox1"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Title") %&gt;'</span> CssClass=<span class="str">"textbox"</span>&gt;&lt;/asp:TextBox&gt;</pre><pre class="alt">            &lt;/InsertItemTemplate&gt;</pre><pre>            &lt;ItemTemplate&gt;</pre><pre class="alt">                &lt;asp:Label ID=<span class="str">"Label1"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Title") %&gt;'</span>&gt;&lt;/asp:Label&gt;</pre><pre>            &lt;/ItemTemplate&gt;</pre><pre class="alt">        &lt;/asp:TemplateField&gt;</pre><pre>        &lt;asp:TemplateField HeaderText=<span class="str">"Description:"</span> HeaderStyle-VerticalAlign=<span class="str">"Top"</span> SortExpression=<span class="str">"Description"</span></pre><pre class="alt">            HeaderStyle-Font-Bold=<span class="str">"true"</span>&gt;</pre><pre>            &lt;EditItemTemplate&gt;</pre><pre class="alt">                &lt;asp:TextBox ID=<span class="str">"TextBox2"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Description") %&gt;'</span> CssClass=<span class="str">"textarea"</span></pre><pre>                    TextMode=<span class="str">"MultiLine"</span> Rows=<span class="str">"5"</span> Width=<span class="str">"80%"</span>&gt;&lt;/asp:TextBox&gt;</pre><pre class="alt">            &lt;/EditItemTemplate&gt;</pre><pre>            &lt;InsertItemTemplate&gt;</pre><pre class="alt">                &lt;asp:TextBox ID=<span class="str">"TextBox2"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Description") %&gt;'</span> CssClass=<span class="str">"textarea"</span></pre><pre>                    TextMode=<span class="str">"MultiLine"</span> Rows=<span class="str">"5"</span> Width=<span class="str">"80%"</span>&gt;&lt;/asp:TextBox&gt;</pre><pre class="alt">            &lt;/InsertItemTemplate&gt;</pre><pre>            &lt;ItemTemplate&gt;</pre><pre class="alt">                &lt;asp:Label ID=<span class="str">"Label2"</span> runat=<span class="str">"server"</span> Text=<span class="str">'&lt;%# Bind("Description") %&gt;'</span>&gt;&lt;/asp:Label&gt;</pre><pre>            &lt;/ItemTemplate&gt;</pre><pre class="alt">        &lt;/asp:TemplateField&gt;</pre><pre>        &lt;asp:CommandField ShowEditButton=<span class="str">"True"</span> ShowInsertButton=<span class="str">"True"</span> /&gt;</pre><pre class="alt">    &lt;/Fields&gt;</pre><pre>&lt;/asp:DetailsView&gt;</pre></div>
<style type="text/css">.csharpcode-wrapper, .csharpcode-wrapper pre {
  background-color: #f4f4f4;
  border: solid 1px gray;
  cursor: text;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  margin: 20px 0px 10px 0px;
  max-height: 200px;
  overflow: auto;
  padding: 4px 4px 4px 4px;
  width: 97.5%;
}
.csharpcode-wrapper pre {
  border-style: none;
  margin: 0px 0px 0px 0px;
  overflow: visible;
  padding: 0px 0px 0px 0px;
}
.csharpcode, .csharpcode pre, .csharpcode .alt {
  background-color: #f4f4f4;
  border-style: none;
  color: black;
  font-family: consolas, 'Courier New', courier, monospace;
  font-size: 8pt;
  line-height: 12pt;
  overflow: visible;
  padding: 0px 0px 0px 0px;
  width: 100%;
}
.csharpcode pre {
  margin: 0em;
}
.csharpcode .alt {
  background-color: white;
}
.csharpcode .asp {
  background-color: #ffff00;
}
.csharpcode .attr {
  color: #ff0000;
}
.csharpcode .html {
  color: #800000;
}
.csharpcode .kwrd {
  color: #0000ff;
}
.csharpcode .lnum {
  color: #606060;
}
.csharpcode .op {
  color: #0000c0;
}
.csharpcode .preproc {
  color: #cc6633;
}
.csharpcode .rem {
  color: #008000;
}
.csharpcode .str {
  color: #006080;
}
</style>
</div>
<p><font face="Segoe UI" size="2">Check out the following: </font></p>
<p><font face="Segoe UI" size="2">We have set <em>DataKeyField</em> to the Primary Key and set the datasource ID to <br>an <em>ObjectDataSource</em> called <em>"odsDetailView"</em>. It fetches all the data via the<br>Business layer and it doesn't need to go to the DAL. </font>
<p><font face="Segoe UI" size="2">The ObjectDataSource truely helps us to build a 3-tier application. <br>Earlier, in this model the UI layer used to bind directly to the Data layer. <br>This actually used to break the tier, and caused scalability and <br>maintenance hassles. </font>
<p><font face="Segoe UI" size="2">We have <em>OnItemInserted</em> and <em>OnItemUpdated</em> events handled to refresh the<br>GridView whenever an update is made using the DetailsView. </font></p>
<div class="csharpcode-wrapper" style="width: 47.37%; height: 79px"><pre class="csharpcode">&lt;asp:DetailsView ID=<span class="str">"EntityDetailsView"</span> runat=<span class="str">"server"</span> AutoGenerateRows=<span class="str">"False"</span> DataKeyNames=<span class="str">"EntityID"</span>    
 DataSourceID=<span class="str">"odsDetailView"</span> Height=<span class="str">"50px"</span> Width=<span class="str">"100%"</span> OnItemInserted=<span class="str">"EntityDetailsView_ItemInserted"</span>    
 OnItemUpdated=<span class="str">"EntityDetailsView_ItemUpdated"</span>&gt;</pre></div>
<p><font face="Segoe UI" size="2">So, whenever you click on the Select button in a row inside the GridView,<br>the <em>ObjectDataSource</em> retrieves the <em>PrimaryKey</em> from the <em>SelectedValue</em> property<br>of the GridView. See the definition of the ASP <em>ControlParameter</em> below.</font></p>
<div class="csharpcode-wrapper" style="width: 47.54%; height: 138px">
<div class="csharpcode"><pre class="alt">&lt;SelectParameters&gt;</pre><pre>    &lt;asp:SessionParameter DefaultValue=<span class="str">"fareast\sanjeets"</span> Name=<span class="str">"UserID"</span> SessionField=<span class="str">"UserID"</span></pre><pre class="alt">        Type=<span class="str">"String"</span> /&gt;</pre><pre>    &lt;asp:ControlParameter ControlID=<span class="str">"MainGrid"</span> Name=<span class="str">"EntityID"</span> PropertyName=<span class="str">"SelectedValue"</span></pre><pre class="alt">        Type=<span class="str">"Int32"</span> /&gt;</pre><pre>&lt;/SelectParameters&gt;</pre></div></div>
<p>&nbsp;</p>
<p><font face="Segoe UI" size="2">So far, we have discussed how the controls interact with each other to give you<br>you a nice clutter free UI for simple operations like Insert, Update, and Delete.<br>Now, lets move on the bigger picture. </font></p>
<p><font face="Segoe UI" size="2">I have entered about 50K rows in the Entities table. </font>
<p><font face="Segoe UI" size="2">Fair enough, I need paging now. Talking about normal paging would be painful, <br>so thats ruled out (I hope you understand what does the normal paging will <br>do, it will bring all 50K rows and show you 10 rows... it hurts). </font>
<p><font face="Segoe UI" size="2">GridView alongwith ObjectDataSource brings to CustomPaging, so all you have to do,<br>is to use the magic of Row_Number in Sql Server 2005 to bring sequential rows.<br>But, thats again almost codeless. So, you have lesser control over it? I hope you<br>still remember scalability? right?</font></p>
<p><font face="Segoe UI" size="2">Refer to&nbsp;<a href="https://weblogs.asp.net/scottgu/archive/2006/01/01/434314.aspx">Paging through lots of data efficiently (and in an Ajax way) with ASP.NET 2.0</a></font><font face="Segoe UI" size="2"> for more <br>information about how to almost codelessly implement custom paging.</font></p>
<p>&nbsp;</p>
<p><font face="Segoe UI" size="2">Lets take a look into the 2 Stored Procedures:<br>The first one as the name suggests Selects Paged rows by a given condition.</font></p>
<div class="csharpcode-wrapper" style="width: 47.47%; height: 143px">
<div class="csharpcode"><pre class="alt"><span class="kwrd">ALTER</span> <span class="kwrd">Procedure</span> [dbo].[SelectPagedEntityByUser]</pre><pre>    @StartRowIndex <span class="kwrd">int</span>,</pre><pre class="alt">    @MaximumRows <span class="kwrd">int</span>,</pre><pre>    @UserID <span class="kwrd">varchar</span>(50)</pre><pre class="alt"><span class="kwrd">AS</span></pre><pre><span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre class="alt">    <span class="kwrd">From</span> AllEntities</pre><pre><span class="kwrd">Where</span> </pre><pre class="alt">    SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre>    <span class="kwrd">AND</span> UserID = @UserID</pre></div></div>
<p><font face="Segoe UI" size="2">It uses the following view:</font></p>
<div class="csharpcode-wrapper" style="width: 47.48%; height: 101px">
<div class="csharpcode"><pre class="alt"><span class="kwrd">ALTER</span> <span class="kwrd">View</span> [dbo].[AllEntities]</pre><pre><span class="kwrd">AS</span></pre><pre class="alt"><span class="kwrd">Select</span> </pre><pre>    EntityID, UserID, Title, [Description], </pre><pre class="alt">    Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> EntityID) <span class="kwrd">as</span> SrNum</pre><pre><span class="kwrd">From</span> Entity</pre></div></div>
<p><font face="Segoe UI" size="2">The second one, as the name suggests Selects Paged rows by a given condition with a sort<br>condition:</font></p>
<div class="csharpcode-wrapper" style="width: 47.76%; height: 276px">
<div class="csharpcode"><pre class="alt"><span class="kwrd">ALTER</span> <span class="kwrd">Procedure</span> [dbo].[SelectPagedEntityByUserOrdered]</pre><pre>    @StartRowIndex <span class="kwrd">int</span>,</pre><pre class="alt">    @MaximumRows <span class="kwrd">int</span>,</pre><pre>    @UserID <span class="kwrd">varchar</span>(50),</pre><pre class="alt">    @ColumnToOrder <span class="kwrd">varchar</span>(50),</pre><pre>    @OrderDirection <span class="kwrd">varchar</span>(10)</pre><pre class="alt"><span class="kwrd">AS</span></pre><pre><span class="kwrd">if</span> @ColumnToOrder <span class="kwrd">like</span> <span class="str">'%ID'</span></pre><pre class="alt"><span class="kwrd">begin</span></pre><pre>    <span class="kwrd">if</span> @OrderDirection = <span class="str">'asc'</span></pre><pre class="alt">        <span class="kwrd">begin</span></pre><pre>            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre class="alt">                <span class="kwrd">From</span> (</pre><pre>                        <span class="kwrd">Select</span> </pre><pre class="alt">                            EntityID, UserID, Title, [Description], </pre><pre>                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> EntityID) <span class="kwrd">as</span> SrNum</pre><pre class="alt">                        <span class="kwrd">From</span> Entity</pre><pre>                    ) <span class="kwrd">as</span> temp</pre><pre class="alt">            <span class="kwrd">Where</span> </pre><pre>                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre class="alt">                <span class="kwrd">AND</span> UserID = @UserID</pre><pre>        <span class="kwrd">end</span></pre><pre class="alt">    <span class="kwrd">else</span></pre><pre>        <span class="kwrd">begin</span></pre><pre class="alt">            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre>                <span class="kwrd">From</span> (</pre><pre class="alt">                        <span class="kwrd">Select</span> </pre><pre>                            EntityID, UserID, Title, [Description], </pre><pre class="alt">                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> EntityID <span class="kwrd">DESC</span>) <span class="kwrd">as</span> SrNum</pre><pre>                        <span class="kwrd">From</span> Entity</pre><pre class="alt">                    ) <span class="kwrd">as</span> temp</pre><pre>            <span class="kwrd">Where</span> </pre><pre class="alt">                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre>                <span class="kwrd">AND</span> UserID = @UserID</pre><pre class="alt">        <span class="kwrd">end</span></pre><pre><span class="kwrd">end</span></pre><pre class="alt"><span class="kwrd">if</span> @ColumnToOrder = <span class="str">'title'</span></pre><pre><span class="kwrd">begin</span></pre><pre class="alt">    <span class="kwrd">if</span> @OrderDirection = <span class="str">'asc'</span></pre><pre>        <span class="kwrd">begin</span></pre><pre class="alt">            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre>                <span class="kwrd">From</span> (</pre><pre class="alt">                        <span class="kwrd">Select</span> </pre><pre>                            EntityID, UserID, Title, [Description], </pre><pre class="alt">                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> Title) <span class="kwrd">as</span> SrNum</pre><pre>                        <span class="kwrd">From</span> Entity</pre><pre class="alt">                    ) <span class="kwrd">as</span> temp</pre><pre>            <span class="kwrd">Where</span> </pre><pre class="alt">                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre>                <span class="kwrd">AND</span> UserID = @UserID</pre><pre class="alt">        <span class="kwrd">end</span></pre><pre>    <span class="kwrd">else</span></pre><pre class="alt">        <span class="kwrd">begin</span></pre><pre>            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre class="alt">                <span class="kwrd">From</span> (</pre><pre>                        <span class="kwrd">Select</span> </pre><pre class="alt">                            EntityID, UserID, Title, [Description], </pre><pre>                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> Title <span class="kwrd">DESC</span>) <span class="kwrd">as</span> SrNum</pre><pre class="alt">                        <span class="kwrd">From</span> Entity</pre><pre>                    ) <span class="kwrd">as</span> temp</pre><pre class="alt">            <span class="kwrd">Where</span> </pre><pre>                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre class="alt">                <span class="kwrd">AND</span> UserID = @UserID</pre><pre>        <span class="kwrd">end</span></pre><pre class="alt"><span class="kwrd">end</span></pre><pre><span class="kwrd">if</span> @ColumnToOrder <span class="kwrd">like</span> <span class="str">'desc%'</span></pre><pre class="alt"><span class="kwrd">begin</span></pre><pre>    <span class="kwrd">if</span> @OrderDirection = <span class="str">'asc'</span></pre><pre class="alt">        <span class="kwrd">begin</span></pre><pre>            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre class="alt">                <span class="kwrd">From</span> (</pre><pre>                        <span class="kwrd">Select</span> </pre><pre class="alt">                            EntityID, UserID, Title, [Description], </pre><pre>                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> [Description]) <span class="kwrd">as</span> SrNum</pre><pre class="alt">                        <span class="kwrd">From</span> Entity</pre><pre>                    ) <span class="kwrd">as</span> temp</pre><pre class="alt">            <span class="kwrd">Where</span> </pre><pre>                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre class="alt">                <span class="kwrd">AND</span> UserID = @UserID</pre><pre>        <span class="kwrd">end</span></pre><pre class="alt">    <span class="kwrd">else</span>        </pre><pre>        <span class="kwrd">begin</span></pre><pre class="alt">            <span class="kwrd">Select</span> EntityID, UserID, Title, [Description]</pre><pre>                <span class="kwrd">From</span> (</pre><pre class="alt">                        <span class="kwrd">Select</span> </pre><pre>                            EntityID, UserID, Title, [Description], </pre><pre class="alt">                            Row_Number() <span class="kwrd">Over</span>(<span class="kwrd">Order</span> <span class="kwrd">By</span> [Description] <span class="kwrd">DESC</span>) <span class="kwrd">as</span> SrNum</pre><pre>                        <span class="kwrd">From</span> Entity</pre><pre class="alt">                    ) <span class="kwrd">as</span> temp</pre><pre>            <span class="kwrd">Where</span> </pre><pre class="alt">                SrNum <span class="kwrd">Between</span> @StartRowIndex <span class="kwrd">AND</span> (@StartRowIndex+@MaximumRows)-1</pre><pre>                <span class="kwrd">AND</span> UserID = @UserID</pre><pre class="alt">        <span class="kwrd">end</span></pre><pre>end</pre></div></div>
<p><font face="Segoe UI" size="2">Their corresponding functions in the BL looks like the following:<br>Notice the use of Generics.<br>For the unsorted:</font></p>
<div class="csharpcode-wrapper" style="width: 48.03%; height: 224px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This function return a strongly type list containing paged data</span></pre><pre class="alt"><span class="rem">/// A benefit of using Generic here is to minimize the size of the object</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="StartRowIndex"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="MaximumRows"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre class="alt"><span class="kwrd">public</span> List&lt;Entity&gt; Select(<span class="kwrd">string</span> UserID, <span class="kwrd">int</span> StartRowIndex, <span class="kwrd">int</span> MaximumRows)</pre><pre>{</pre><pre class="alt">    ManageabilityDS.EntityDataTable tbl = <span class="kwrd">null</span>;</pre><pre>    List&lt;Entity&gt; t = <span class="kwrd">new</span> List&lt;Entity&gt;(); </pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre>        <span class="rem">//GetPagedEntityByUser function is defined in the DataSet</span></pre><pre class="alt">        tbl = ad.GetPagedEntityByUser(StartRowIndex, MaximumRows, UserID);</pre><pre>        <span class="rem">//fill the strongly typed List with data</span></pre><pre class="alt">        <span class="kwrd">foreach</span> (ManageabilityDS.EntityRow row <span class="kwrd">in</span> tbl.Rows)</pre><pre>        {</pre><pre class="alt">            Entity en = <span class="kwrd">new</span> Entity();</pre><pre>            en.EntityID = row.EntityID;</pre><pre class="alt">            en.UserId = row.UserID;</pre><pre>            en.Title = row.Title;</pre><pre class="alt">            en.Description = row.Description;</pre><pre>            t.Add(en);</pre><pre class="alt">        }</pre><pre>        <span class="kwrd">return</span> t;</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span></pre><pre class="alt">    {</pre><pre>        <span class="kwrd">throw</span>;</pre><pre class="alt">    }</pre><pre>}</pre></div></div>
<p><font face="Segoe UI" size="2">For the sorted:</font></p>
<div class="csharpcode-wrapper" style="width: 48.29%; height: 208px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This function return a strongly type list containing paged and sorted data</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="rem">/// &lt;param name="UserID"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="StartRowIndex"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="MaximumRows"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="ColumnToOrder"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="OrderDirection"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre><pre><span class="kwrd">public</span> List&lt;Entity&gt; Select(<span class="kwrd">string</span> UserID, <span class="kwrd">int</span> StartRowIndex, <span class="kwrd">int</span> MaximumRows, <span class="kwrd">string</span> ColumnToOrder, <span class="kwrd">string</span> OrderDirection)</pre><pre class="alt">{</pre><pre>    ManageabilityDS.EntityDataTable tbl = <span class="kwrd">null</span>;</pre><pre class="alt">    List&lt;Entity&gt; t = <span class="kwrd">new</span> List&lt;Entity&gt;();</pre><pre>    <span class="kwrd">try</span></pre><pre class="alt">    {</pre><pre>        ManageabilityDSTableAdapters.EntityTableAdapter ad = <span class="kwrd">new</span> ManageabilityDSTableAdapters.EntityTableAdapter();</pre><pre class="alt">        <span class="rem">//GetPagedEntityByUserOrdered function is defined in the DataSet</span></pre><pre>        tbl = ad.GetPagedEntityByUserOrdered(StartRowIndex, MaximumRows, UserID, ColumnToOrder, OrderDirection);</pre><pre class="alt">        <span class="rem">//fill the strongly typed List with data</span></pre><pre>        <span class="kwrd">foreach</span> (ManageabilityDS.EntityRow row <span class="kwrd">in</span> tbl.Rows)</pre><pre class="alt">        {</pre><pre>            Entity en = <span class="kwrd">new</span> Entity();</pre><pre class="alt">            en.EntityID = row.EntityID;</pre><pre>            en.UserId = row.UserID;</pre><pre class="alt">            en.Title = row.Title;</pre><pre>            en.Description = row.Description;</pre><pre class="alt">            t.Add(en);</pre><pre>        }</pre><pre class="alt">        <span class="kwrd">return</span> t;</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">catch</span></pre><pre>    {</pre><pre class="alt">        <span class="kwrd">throw</span>;</pre><pre>    }</pre><pre class="alt">}</pre></div></div>
<p>&nbsp;</p>
<p><font face="Segoe UI" size="2">Let's get back to the Presentation Layer. Here, as part of customization we have the<br>GridView inside a table which is sitting inside an asp:UpdatePanel... AJAX effect!!!<br>Simple, sweet and effective. </font></p>
<p><font face="Segoe UI" size="2">We had to create the PageLinks for navigation. The ellipsis and all other links are created<br>on the fly and provides smooth and fast navigation at any point.<br>When you click on the link, only PageSize number of rows are fetched from the database,<br>so practically it doesn't matter if you have 50K or 500K records!!! </font>
<p><font face="Segoe UI" size="2">Lets see how the Links are created:</font></p>
<div class="csharpcode-wrapper" style="width: 48.6%; height: 175px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This sub creates all the links on the page</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="kwrd">private</span> <span class="kwrd">void</span> CreateButtons()</pre><pre class="alt">{       </pre><pre>    <span class="kwrd">int</span> totalRecords = <span class="kwrd">int</span>.Parse(RecordCountHdn.Value);</pre><pre class="alt">    <span class="kwrd">int</span> pageSize = <span class="kwrd">int</span>.Parse(PageSizeHdn.Value);</pre><pre>&nbsp;</pre><pre class="alt">    <span class="rem">//calculate the total number of links to be created</span></pre><pre>    <span class="kwrd">int</span> totalPages = totalRecords % pageSize == 0 ? totalRecords / pageSize : (totalRecords / pageSize) + 1;</pre><pre class="alt">&nbsp;</pre><pre>    <span class="rem">//this is for the ellipsis, keeps a track of the previous bunch of links</span></pre><pre class="alt">    <span class="kwrd">int</span> x = <span class="kwrd">int</span>.Parse(ViewState[<span class="str">"PageLinkLastBunchCount"</span>].ToString());</pre><pre>&nbsp;</pre><pre class="alt">    <span class="rem">//its the counter that checks whether all the links are created</span></pre><pre>    <span class="kwrd">int</span> p = MAX_PAGE_LINKS * (x + 1);</pre><pre class="alt">    </pre><pre>    <span class="rem">//The ellipsis linkbutton</span></pre><pre class="alt">    LinkButton ellipsis = <span class="kwrd">null</span>;</pre><pre>&nbsp;</pre><pre class="alt">    <span class="rem">////To AJAXify the linkbuttons you need to have triggers</span></pre><pre>    AsyncPostBackTrigger t = <span class="kwrd">null</span>;</pre><pre class="alt">&nbsp;</pre><pre>    <span class="rem">//clear any previous links in the placeholder</span></pre><pre class="alt">    PageLinksPH.Controls.Clear();</pre><pre>&nbsp;</pre><pre class="alt">    <span class="kwrd">if</span> (p &lt; totalPages)</pre><pre>    {</pre><pre class="alt">        <span class="rem">//if you are on the first bunch of links</span></pre><pre>        <span class="kwrd">if</span> (x == 0)</pre><pre class="alt">        {                </pre><pre>            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = MAX_PAGE_LINKS * x; i &lt; p; i++)</pre><pre class="alt">            {</pre><pre>                LinkButton l = <span class="kwrd">new</span> LinkButton();</pre><pre class="alt">                l.ID = <span class="str">"pagelink"</span>+i;</pre><pre>                l.Text = <span class="kwrd">string</span>.Format(<span class="str">"{0}"</span>, i + 1);</pre><pre class="alt">                l.ToolTip = <span class="kwrd">string</span>.Format(<span class="str">"{0}+..."</span>, (i * pageSize) + 1);</pre><pre>                l.CommandArgument = <span class="kwrd">string</span>.Format(<span class="str">"{0}"</span>, (i * pageSize) + 1);</pre><pre class="alt">                l.CssClass = <span class="str">"pagelink"</span>;</pre><pre>                <span class="rem">//add event handler to each linkbutton</span></pre><pre class="alt">                l.Click += <span class="kwrd">new</span> EventHandler(l_Click);</pre><pre>                PageLinksPH.Controls.Add(l);</pre><pre class="alt">                t = <span class="kwrd">new</span> AsyncPostBackTrigger();</pre><pre>                t.ControlID = l.ID;</pre><pre class="alt">                AjaxPanel.Triggers.Add(t);</pre><pre>            }</pre><pre class="alt">            ellipsis = <span class="kwrd">new</span> LinkButton();</pre><pre>            ellipsis.ID = <span class="str">"ellipsisNext"</span>;</pre><pre class="alt">            ellipsis.Text = <span class="str">"&gt;&gt;"</span>;</pre><pre>            ellipsis.ToolTip = <span class="str">"Next"</span>;</pre><pre class="alt">            ellipsis.CommandArgument = <span class="kwrd">string</span>.Format(<span class="str">"next"</span>);</pre><pre>            ellipsis.CssClass = <span class="str">"pagelink"</span>;</pre><pre class="alt">            <span class="rem">//add event handler to each linkbutton</span></pre><pre>            ellipsis.Click += <span class="kwrd">new</span> EventHandler(ellipsis_Click);</pre><pre class="alt">            PageLinksPH.Controls.Add(ellipsis);</pre><pre>            t = <span class="kwrd">new</span> AsyncPostBackTrigger();</pre><pre class="alt">            t.ControlID = ellipsis.ID;</pre><pre>            AjaxPanel.Triggers.Add(t);</pre><pre class="alt">        }</pre><pre>        <span class="kwrd">else</span> <span class="rem">//this will show next and the previous ellipsis</span></pre><pre class="alt">        {</pre><pre>            ellipsis = <span class="kwrd">new</span> LinkButton();</pre><pre class="alt">            ellipsis.Text = <span class="str">"&lt;&lt;"</span>;</pre><pre>            ellipsis.ID = <span class="str">"ellipsisPrevious"</span>;</pre><pre class="alt">            ellipsis.ToolTip = <span class="str">"Previous"</span>;</pre><pre>            ellipsis.CommandArgument = <span class="kwrd">string</span>.Format(<span class="str">"previous"</span>);</pre><pre class="alt">            ellipsis.CssClass = <span class="str">"pagelink"</span>;</pre><pre>            <span class="rem">//add event handler to each linkbutton</span></pre><pre class="alt">            ellipsis.Click += <span class="kwrd">new</span> EventHandler(ellipsis_Click);</pre><pre>            PageLinksPH.Controls.Add(ellipsis);</pre><pre class="alt">            t = <span class="kwrd">new</span> AsyncPostBackTrigger();</pre><pre>            t.ControlID = ellipsis.ID;</pre><pre class="alt">            AjaxPanel.Triggers.Add(t);</pre><pre>            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = MAX_PAGE_LINKS * x; i &lt; p; i++)</pre><pre class="alt">            {</pre><pre>                LinkButton l = <span class="kwrd">new</span> LinkButton();</pre><pre class="alt">                l.ID = <span class="str">"pagelink"</span> + i;</pre><pre>                l.Text = <span class="kwrd">string</span>.Format(<span class="str">"{0}"</span>, i + 1);</pre><pre class="alt">                l.ToolTip = <span class="kwrd">string</span>.Format(<span class="str">"{0}+..."</span>, (i * pageSize) + 1);</pre><pre>                l.CommandArgument = <span class="kwrd">string</span>.Format(<span class="str">"{0}"</span>, (i * pageSize) + 1);</pre><pre class="alt">                l.CssClass = <span class="str">"pagelink"</span>;</pre><pre>                <span class="rem">//add event handler to each linkbutton</span></pre><pre class="alt">                l.Click += <span class="kwrd">new</span> EventHandler(l_Click);</pre><pre>                PageLinksPH.Controls.Add(l);</pre><pre class="alt">                t = <span class="kwrd">new</span> AsyncPostBackTrigger();</pre><pre>                t.ControlID = l.ID;</pre><pre class="alt">                AjaxPanel.Triggers.Add(t);</pre><pre>            }</pre><pre class="alt">            ellipsis = <span class="kwrd">new</span> LinkButton();</pre><pre>            ellipsis.ID = <span class="str">"ellipsisNext"</span>;</pre><pre class="alt">            ellipsis.Text = <span class="str">"&gt;&gt;"</span>;</pre><pre>            ellipsis.ToolTip = <span class="str">"Next"</span>;</pre><pre class="alt">            ellipsis.CommandArgument = <span class="kwrd">string</span>.Format(<span class="str">"next"</span>);</pre><pre>            ellipsis.CssClass = <span class="str">"pagelink"</span>;</pre><pre class="alt">            <span class="rem">//add event handler to each linkbutton</span></pre><pre>            ellipsis.Click += <span class="kwrd">new</span> EventHandler(ellipsis_Click);</pre><pre class="alt">            PageLinksPH.Controls.Add(ellipsis);</pre><pre>            t = <span class="kwrd">new</span> AsyncPostBackTrigger();</pre><pre class="alt">            t.ControlID = ellipsis.ID;</pre><pre>            AjaxPanel.Triggers.Add(t);</pre><pre class="alt">        }</pre><pre>    }        </pre><pre class="alt">}</pre></div></div>
<p><font face="Segoe UI" size="2">Event handler for the ellipsis:</font></p>
<div class="csharpcode-wrapper" style="width: 48.81%; height: 188px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// The ellipsis' event handler. It shows the next/previous bunch of links</span></pre><pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre><pre><span class="rem">/// &lt;param name="sender"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="e"&gt;&lt;/param&gt;</span></pre><pre><span class="kwrd">void</span> ellipsis_Click(<span class="kwrd">object</span> sender, EventArgs e)</pre><pre class="alt">{</pre><pre>    <span class="rem">//throw new Exception("The method or operation is not implemented.");</span></pre><pre class="alt">    LinkButton l = (LinkButton)sender;</pre><pre>    <span class="kwrd">int</span> x = <span class="kwrd">int</span>.Parse(ViewState[<span class="str">"PageLinkLastBunchCount"</span>].ToString());</pre><pre class="alt">    <span class="kwrd">if</span> (l.CommandArgument.ToLower().Equals(<span class="str">"previous"</span>))</pre><pre>    {            </pre><pre class="alt">        x--;</pre><pre>    }</pre><pre class="alt">    <span class="kwrd">else</span> <span class="kwrd">if</span> (l.CommandArgument.ToLower().Equals(<span class="str">"next"</span>))</pre><pre>    {</pre><pre class="alt">        x++;        </pre><pre>    }</pre><pre class="alt">    ViewState[<span class="str">"PageLinkLastBunchCount"</span>] = x;</pre><pre>    CreateButtons();</pre><pre class="alt">}</pre></div></div>
<p><font face="Segoe UI" size="2">Event handler for the links:</font></p>
<div class="csharpcode-wrapper" style="width: 48.73%; height: 158px">
<div class="csharpcode"><pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre><pre><span class="rem">/// This handler will send the query to the database fetching the </span></pre><pre class="alt"><span class="rem">/// exact number of records only. It also takes care of sorting.</span></pre><pre><span class="rem">/// &lt;/summary&gt;</span></pre><pre class="alt"><span class="rem">/// &lt;param name="sender"&gt;&lt;/param&gt;</span></pre><pre><span class="rem">/// &lt;param name="e"&gt;&lt;/param&gt;</span></pre><pre class="alt"><span class="kwrd">void</span> l_Click(<span class="kwrd">object</span> sender, EventArgs e)</pre><pre>{</pre><pre class="alt">    <span class="rem">//throw new Exception("The method or operation is not implemented.");</span></pre><pre>    <span class="rem">//Response.Write("l_Click");</span></pre><pre class="alt">    <span class="kwrd">try</span></pre><pre>    {</pre><pre class="alt">        LinkButton l = (LinkButton)sender;</pre><pre>        l.CssClass = <span class="str">"pagelinkSelected"</span>;</pre><pre class="alt">        <span class="kwrd">int</span> startIndex = <span class="kwrd">int</span>.Parse(l.CommandArgument);</pre><pre>        ViewState[<span class="str">"PageStartIndex"</span>] = startIndex;</pre><pre class="alt">        <span class="kwrd">int</span> pageSize = <span class="kwrd">int</span>.Parse(PageSizeHdn.Value);</pre><pre>        <span class="kwrd">using</span> (Entity en = <span class="kwrd">new</span> Entity())</pre><pre class="alt">        {</pre><pre>            <span class="kwrd">if</span> (_isPageSorted)</pre><pre class="alt">            {</pre><pre>                MainGrid.DataSource = en.Select(_userID, startIndex, pageSize, ColumnList.SelectedValue.ToString(), OrderDirectionList.SelectedValue.ToString());</pre><pre class="alt">            }</pre><pre>            <span class="kwrd">else</span></pre><pre class="alt">            {</pre><pre>                MainGrid.DataSource = en.Select(_userID, startIndex, pageSize);</pre><pre class="alt">            }</pre><pre>            MainGrid.DataBind();</pre><pre class="alt">        }</pre><pre>        InfoLabel.Text = <span class="kwrd">string</span>.Format(<span class="str">"You are at Page# {0}"</span>, l.Text);</pre><pre class="alt">    }</pre><pre>    <span class="kwrd">catch</span>(Exception ex)</pre><pre class="alt">    {</pre><pre>        ErrorLabel.Text = ex.Message;</pre><pre class="alt">    }</pre><pre>}</pre></div></div>
<p><font face="Segoe UI" size="2">After you follow the steps above, I am sure it will be a cake walk for you all to create<br>or maintain any such page. It might appear to be lots of work, but its highly reliable<br>and scalable. No blackboxes!!! </font>
<p><font face="Segoe UI" size="2">So, this brings us to an end of this long post, I sincerely hope it will help you a lot.</font> 
<p><font face="Segoe UI" size="2">See you soon...</font></p>]]></content:encoded>
    </item>
  </channel>
</rss>