<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>Scott Klueppel's Blog</title>
  <link rel="alternate" type="text/html" href="http://scott.klueppel.net/" />
  <link rel="self" href="http://scott.klueppel.net/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-09-07T05:15:32.2453334-07:00</updated>
  <author>
    <name>Scott Klueppel</name>
  </author>
  <subtitle>.NET Discourse</subtitle>
  <id>http://scott.klueppel.net/</id>
  <generator uri="http://dasblog.info/" version="2.1.8102.813">DasBlog</generator>
  <entry>
    <title>ROW_NUMBER()</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/09/07/ROWNUMBER.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,4118ae7f-25e1-4d3a-8256-a57596277005.aspx</id>
    <published>2008-09-06T20:33:25.996-07:00</published>
    <updated>2008-09-06T20:35:07.042875-07:00</updated>
    <category term="SQL" label="SQL" scheme="http://scott.klueppel.net/CategoryView,category,SQL.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I really need to read up on new features when a major release comes out. Just a few
weeks ago I learned of a great "new" SQL 2005 function... ROW_NUMBER(). Just in time
since SQL 2008 is already out. 
</p>
        <p>
For me, this function means a lot less temp tables. I would typically create a temp
table with an <font color="#0000ff">ID INT IDENTITY(1,1)</font> column to create an
DisplayOrder, BatchID, etc. used to group or join on later. Books Online describes
the function as "Returns the sequential number of a row within a partition of a result
set, starting at 1 for the first row in each partition." The syntax is simple, and
looks like:
</p>
        <blockquote>
          <p>
            <font color="#ff00ff">ROW_NUMBER</font>() <font color="#0000ff">OVER</font> (<font color="#0000ff">ORDER
BY</font> ID <font color="#0000ff">DESC</font>)
</p>
        </blockquote>
        <p>
For this example, the data I want to bring back with a <em>DisplayOrder</em> column
looks like:
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ROW_NUMBER_147E9/pers_subs_data.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="148" alt="pers_subs_data" src="http://scott.klueppel.net/content/binary/ROW_NUMBER_147E9/pers_subs_data_thumb.png" width="506" border="0" />
          </a>
        </p>
        <p>
          <u>Without ROW_NUMBER(), using a table variable with an identity column:</u>
        </p>
        <blockquote>
          <p>
            <font color="#0000ff">DECLARE</font> @Subs <font color="#0000ff">TABLE</font> (DisplayOrder<font color="#0000ff"> INT
IDENTITY</font>(1,1), [Address] <font color="#0000ff">VARCHAR</font>(100), Operation <font color="#0000ff">VARCHAR</font>(50),
[Contract] <font color="#0000ff">VARCHAR</font>(50)) 
</p>
          <p>
            <font color="#0000ff">INSERT INTO</font> @Subs ([Address], Operation, [Contract])<br /><font color="#0000ff">SELECT</font> [Address]<br />
    , Operation<br />
    , [Contract]<br /><font color="#0000ff">FROM</font> PersistentSubscribers<br /><font color="#0000ff">WHERE</font> Operation = 'OnEvent2'<br /><font color="#0000ff">ORDER BY <font color="#000000">ID</font> DESC</font></p>
          <p>
            <font color="#0000ff">SELECT <font color="#000000">*</font> FROM</font> @Subs 
</p>
        </blockquote>
        <p>
          <u>With ROW_NUMBER(), look how beautiful:</u>
        </p>
        <blockquote>
          <p>
            <font color="blue">SELECT</font> DisplayOrder = <font color="#ff00ff">ROW_NUMBER</font>() <font color="#0000ff">OVER</font> (<font color="#0000ff">ORDER
BY</font> ID <font color="#0000ff">DESC</font>)<br />
    , [Address]<br />
    , Operation<br />
    , [Contract]<br /><font color="#0000ff">FROM</font> PersistentSubscribers<br /><font color="#0000ff">WHERE</font> Operation = 'OnEvent2'
</p>
        </blockquote>
        <p>
The results from both methods looks like: 
</p>
        <p>
  
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ROW_NUMBER_147E9/row_number_results.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="122" alt="row_number_results" src="http://scott.klueppel.net/content/binary/ROW_NUMBER_147E9/row_number_results_thumb.png" width="456" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=4118ae7f-25e1-4d3a-8256-a57596277005" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Error Log RSS Feed</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/08/31/ErrorLogRSSFeed.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,81c4ce95-c3f1-4bda-97cf-f344afba5a2d.aspx</id>
    <published>2008-08-31T01:37:38-07:00</published>
    <updated>2008-09-06T19:08:38.746-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="LINQ" label="LINQ" scheme="http://scott.klueppel.net/CategoryView,category,LINQ.aspx" />
    <category term="WCF" label="WCF" scheme="http://scott.klueppel.net/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Why clutter your inbox with error messages? Why make special code provisions for users
to receive error messages via email? Why not log your error messages and have users
subscribe to receive them in their favorite RSS aggregator?
</p>
        <p>
If you are logging your exceptions already, you may find it easier to provide a syndication
service. The process is ridiculously simple, and starts by creating a new project
using the "Syndication Service Library" template. This template creates everything
for you. All you need to do now is fill the <em>SyndicationFeed</em> with <em>SyndicationItem</em> objects.
</p>
        <p>
Add a new class file called Feeds.cs: 
</p>
        <p>
 
</p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 873px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    1</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    2</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Linq</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    3</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    4</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>.<span style="COLOR: #dfdfbf">Syndication</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    5</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>.<span style="COLOR: #dfdfbf">Web</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    6</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    7</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">namespace</span><span style="COLOR: #dfdfbf">SyndicationService</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    8</span> {</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    9</span>    
[<span style="COLOR: #2b91af">ServiceContract</span>]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   10</span>    
[<span style="COLOR: #2b91af">ServiceKnownType</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">typeof</span>(<span style="COLOR: #2b91af">Atom10FeedFormatter</span>))]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   11</span>    
[<span style="COLOR: #2b91af">ServiceKnownType</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">typeof</span>(<span style="COLOR: #2b91af">Rss20FeedFormatter</span>))]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   12</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">interface</span><span style="COLOR: #2b91af">IFeeds</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   13</span>    
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   14</span>        
[<span style="COLOR: #2b91af">OperationContract</span>]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   15</span>        
[<span style="COLOR: #2b91af">WebGet</span>(<span style="COLOR: #dfdfbf">UriTemplate</span> = <span style="COLOR: #c89191">"{type}?env={env}&amp;app={app}"</span>, <span style="COLOR: #dfdfbf">BodyStyle</span> = <span style="COLOR: #2b91af">WebMessageBodyStyle</span>.<span style="COLOR: #dfdfbf">Bare</span>)]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   16</span>         <span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">CreateFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   17</span>    
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   18</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   19</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">class</span><span style="COLOR: #2b91af">Feeds</span> : <span style="COLOR: #2b91af">IFeeds</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   20</span>    
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   21</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">CreateFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   22</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   23</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span> = <span style="COLOR: #dfdfbf">CreateSyndicationFeed</span>(<span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   24</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   25</span>             <span style="COLOR: #7f9f7f">//
Return ATOM or RSS based on query string</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   26</span>             <span style="COLOR: #7f9f7f">//
rss -&gt; http://localhost:8000/Feeds/Errors?env=Production&amp;app=MyAppName</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   27</span>             <span style="COLOR: #7f9f7f">//
atom -&gt; http://localhost:8000/Feeds/Errors?env=Production&amp;app=MyAppName&amp;format=atom</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   28</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">query</span> = <span style="COLOR: #2b91af">WebOperationContext</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">IncomingRequest</span>.<span style="COLOR: #dfdfbf">UriTemplateMatch</span>.<span style="COLOR: #dfdfbf">QueryParameters</span>[<span style="COLOR: #c89191">"format"</span>];</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   29</span>             <span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   30</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">if</span> (<span style="COLOR: #dfdfbf">query</span> == <span style="COLOR: #c89191">"atom"</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   31</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   32</span>                 <span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">Atom10FeedFormatter</span>(<span style="COLOR: #dfdfbf">feed</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   33</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   34</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">else</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   35</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   36</span>                 <span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">Rss20FeedFormatter</span>(<span style="COLOR: #dfdfbf">feed</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   37</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   38</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   39</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">formatter</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   40</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   41</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   42</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">private</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">CreateSyndicationFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   43</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   44</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   45</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">switch</span> (<span style="COLOR: #dfdfbf">type</span>.<span style="COLOR: #dfdfbf">ToLower</span>())</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   46</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   47</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">case</span><span style="COLOR: #c89191">"errors"</span>:</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   48</span>                     <span style="COLOR: #dfdfbf">feed</span> = <span style="COLOR: #dfdfbf">CreateErrorsFeed</span>(<span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   49</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">break</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   50</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">default</span>:</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   51</span>                     <span style="COLOR: #dfdfbf">feed</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationFeed</span>(</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   52</span>                         <span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"Feed
is unavailable - Type: {0} / Environment: {1} / Application: {2}"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   53</span>                         <span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>), <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   54</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">break</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   55</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   56</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   57</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   58</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   59</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">private</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">CreateErrorsFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   60</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   61</span>             <span style="COLOR: #2b91af">ApplicationLogDataContext</span><span style="COLOR: #dfdfbf">db</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">ApplicationLogDataContext</span>();</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   62</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   63</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationFeed</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   64</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   65</span>                 <span style="COLOR: #dfdfbf">Title</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"{0}
{1} {2}"</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>, <span style="COLOR: #dfdfbf">type</span>)),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   66</span>                 <span style="COLOR: #dfdfbf">Description</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   67</span>                     <span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"Application
error syndication for the {0} applicaiton ({1})."</span>, <span style="COLOR: #dfdfbf">app</span>, <span style="COLOR: #dfdfbf">env</span>)),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   68</span>                 <span style="COLOR: #dfdfbf">Items</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">from</span><span style="COLOR: #dfdfbf">e</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">in</span><span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">Exceptions</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   69</span>                         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">where</span><span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Environment</span> == <span style="COLOR: #dfdfbf">env</span> &amp;&amp; <span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Application</span> == <span style="COLOR: #dfdfbf">app</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   70</span>                         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">select</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationItem</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   71</span>                        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   72</span>                             <span style="COLOR: #dfdfbf">Title</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Message</span>),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   73</span>                             <span style="COLOR: #dfdfbf">Content</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">StackTrace</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   74</span>                        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   75</span>            
};</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   76</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   77</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   78</span>    
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   79</span> }</strong>
          </p>
        </div>
        <p>
        </p>
        <p>
Modify the App.config file: 
</p>
        <p>
 
</p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 876px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    1</span> <span style="COLOR: #efef8f">&lt;?</span><span style="COLOR: #e3c66a">xml</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">version</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">1.0</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">encoding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">utf-8</span><span style="COLOR: #efef8f">"
?&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    2</span> <span style="COLOR: #efef8f">&lt;</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    3</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">configSections</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    4</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">configSections</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    5</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">connectionStrings</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    6</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">add</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.Properties.Settings.ApplicationLogConnectionString</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    7</span> <span style="COLOR: #efef8f">            </span><span style="COLOR: white">connectionString</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">Data
Source=Scorpion;Initial Catalog=ApplicationLog;Integrated Security=True</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    8</span> <span style="COLOR: #efef8f">            </span><span style="COLOR: white">providerName</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">System.Data.SqlClient</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    9</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">connectionStrings</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   10</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   11</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   12</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.Feeds</span><span style="COLOR: #efef8f">"&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   13</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">host</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">baseAddresses</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span> <span style="COLOR: #efef8f">                       
&lt;</span><span style="COLOR: #e3c66a">add</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">baseAddress</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">http://localhost:8000/</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   16</span> <span style="COLOR: #efef8f">                   
&lt;/</span><span style="COLOR: #e3c66a">baseAddresses</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   17</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">host</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   18</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.IFeeds</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   19</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">Feeds</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   20</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">webHttpBinding</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">behaviorConfiguration</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WebHttpBinding_Common</span><span style="COLOR: #efef8f">"/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">endpointBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   26</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WebHttpBinding_Common</span><span style="COLOR: #efef8f">"&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   27</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">webHttp</span><span style="COLOR: #efef8f">/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   28</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   29</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">endpointBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   30</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   31</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   32</span> <span style="COLOR: #efef8f">&lt;/</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
        </div>
        <p>
        </p>
        <p>
You will need to adjust your project's Debug options to have command arguments that
look similar to the following to F5-debug your service.
</p>
        <blockquote>
          <p>
            <strong>"/client:iexplore.exe" "/clientArgs:http://localhost:8000/Feeds/Errors?env=Production&amp;app=GeoTracker"</strong>
          </p>
        </blockquote>
        <p>
Press F5 to test it out.
</p>
        <p>
Here is the IE7 RSS viewer:
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="425" alt="IE7_RSS_Viewer" src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer_thumb.png" width="602" border="0" />
          </a>
        </p>
        <p>
Here is your RSS aggregator viewing the same feed:
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="387" alt="RSS_Aggregator" src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator_thumb.png" width="602" border="0" />
          </a>
        </p>
        <p>
You will, of course, want to add some additional information to the content of your <em>SyndidationItem</em>,
a bogus phrase works for this example. 
</p>
        <p>
Also, it is unusual that you would care to keep your exception details around for
a long period of time. Since this is a syndicated feed of application errors, you
should make special arrangements to archive or delete your exception log on a regular
basis. This will not only keep your insert and select times low, but will also alleviate
the burden placed on a new subscriber when all of the exceptions from the database
appear at once. An alternative would also be to modify the LINQ in the code above
to only bring back exceptions from the last 7-60 days depending on your counts. I
already archive my exceptions to a master exception repository for all environments
by way of an ETL job. This way I can report on my errors without disturbing the live
environments too.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=81c4ce95-c3f1-4bda-97cf-f344afba5a2d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>C# 3.0 Extension Methods</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/08/27/C30ExtensionMethods.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,08b6d0c7-0e40-4390-af14-a4f2f872ff1a.aspx</id>
    <published>2008-08-26T19:07:12.998-07:00</published>
    <updated>2008-09-07T05:15:32.2453334-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="LINQ" label="LINQ" scheme="http://scott.klueppel.net/CategoryView,category,LINQ.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I decided to come out of my cave and look around 3.5 a bit. I haven't read much about
extension methods, but find them quite useful. They are nothing more than a syntactically
superior static helper method. Let's look at a quick example so I can get back to
coming up with more excuses to use them everywhere.
</p>
        <p>
I like to batch my database calls as much as possible to avoid repeated opening/closing
of connections, etc. To do this, I pass a bunch of ID values into a stored procedure
as a comma-separated string. In the stored proc, I break the string apart with everyone's
favorite table-valued function fn_MakeTable() to make a table of IDs. Then I can JOIN,
UPDATE, or INSERT as needed.
</p>
        <p>
So let's say I have a collection of Orders which I can easily convert to an array
of OrderID integers with LINQ. My new best friend to create a comma-separated string
of OrderIDs is the following. 
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Configuration\cf3 ;\par ??\par ??\cf1 {\b namespace}\cf3  \cf4 Common\par ??\cf3 \{\par ??\tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b class}\cf3  \cf5 ArrayHelper\par ??\cf3 \tab \{\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &lt;\cf4 T\cf3 &gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 Converter\cf3 &lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &gt; \cf4 converter\cf3  = (\cf4 t\cf3 ) =&gt;\par ??\tab \tab \tab \tab \{\par ??\tab \tab \tab \tab \tab \cf1 {\b return}\cf3  \cf4 t\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \tab \tab \};\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 ToCsv\cf3 (\cf4 array\cf3 , \cf4 converter\cf3 );\par ??\tab \tab \}\par ??\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &lt;\cf4 T\cf3 &gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 , \cf5 Converter\cf3 &lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &gt; \cf4 converter\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 CommaDelimitedStringCollection\cf3  \cf4 csv\cf3  = \cf1 {\b new}\cf3  \cf5 CommaDelimitedStringCollection\cf3 ();\par ??\tab \tab \tab \cf1 {\b foreach}\cf3  (\cf4 T\cf3  \cf4 t\cf3  \cf1 {\b in}\cf3  \cf4 array\cf3 )\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 csv\cf3 .\cf4 Add\cf3 (\cf4 converter\cf3 (\cf4 t\cf3 ));\par ??\tab \tab \tab \}\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 csv\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \}\par ??\tab \}\par ??\}}
-->
        <div style="OVERFLOW-Y: scroll; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 760px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    1</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    2</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Configuration</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    3</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    4</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">namespace</span><span style="COLOR: #dfdfbf">Common</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    5</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    6</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">class</span><span style="COLOR: #2b91af">ArrayHelper</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    7</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    8</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">ToCsv</span>&lt;<span style="COLOR: #dfdfbf">T</span>&gt;(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">this</span><span style="COLOR: #dfdfbf">T</span>[] <span style="COLOR: #dfdfbf">array</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    9</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   10</span>             <span style="COLOR: #2b91af">Converter</span>&lt;<span style="COLOR: #dfdfbf">T</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span> =
(<span style="COLOR: #dfdfbf">t</span>) =&gt;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   11</span>                
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   12</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">t</span>.<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   13</span>                
};
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">array</span>, <span style="COLOR: #dfdfbf">converter</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   16</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   17</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">ToCsv</span>&lt;<span style="COLOR: #dfdfbf">T</span>&gt;(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">this</span><span style="COLOR: #dfdfbf">T</span>[] <span style="COLOR: #dfdfbf">array</span>, <span style="COLOR: #2b91af">Converter</span>&lt;<span style="COLOR: #dfdfbf">T</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   18</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   19</span>             <span style="COLOR: #2b91af">CommaDelimitedStringCollection</span><span style="COLOR: #dfdfbf">csv</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">CommaDelimitedStringCollection</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   20</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">foreach</span> (<span style="COLOR: #dfdfbf">T</span><span style="COLOR: #dfdfbf">t</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">in</span><span style="COLOR: #dfdfbf">array</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span>            
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span>                 <span style="COLOR: #dfdfbf">csv</span>.<span style="COLOR: #dfdfbf">Add</span>(<span style="COLOR: #dfdfbf">converter</span>(<span style="COLOR: #dfdfbf">t</span>));
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span>            
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">csv</span>.<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   26</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   27</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
You'll see that I have two ToCsv() methods. The first takes a generic array using
the <strong>this</strong> keyword and uses .ToString() as a default converter to string.
The second method requires you to additionally pass in a converter to convert the
object of type T to a string. Take those converted strings, add them to a <em>CommaDelimitedStringCollection</em> and
.ToString() that collection to a full CSV string of integer values.
</p>
        <p>
There are two ways to call these extension methods. The first is the more familiar
way. Since they are really nothing more than static helper methods, call them just
like any other:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 Common\cf1 .\cf6 ArrayHelper\cf1 .\cf4 ToCsv\cf1 (\cf4 array\cf1 );}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 469px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 34px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>[] <span style="COLOR: #dfdfbf">array</span> =
{ <span style="COLOR: #8acccf">123</span>, <span style="COLOR: #8acccf">456</span> };
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">Common</span>.<span style="COLOR: #2b91af">ArrayHelper</span>.<span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">array</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
The second is the more elegant and more intuitive way. Call it as if it was built
into the Framework: 
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 array\cf1 .\cf4 ToCsv\cf1 ();}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 32px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>[] <span style="COLOR: #dfdfbf">array</span> =
{ <span style="COLOR: #8acccf">123</span>, <span style="COLOR: #8acccf">456</span> };
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">array</span>.<span style="COLOR: #dfdfbf">ToCsv</span>();
</p>
        </div>
        <p>
 
</p>
        <p>
You may be wondering, what if I write a method that matches the signature of a built-in
method like .ToString(). Well, the built-in methods take precedence over extension
methods, so <strong>array.ToString()</strong> will still appear as <strong>System.Int32[]</strong>.
To get your new meaning of .ToString(), you just have to call it in the static helper
method way detailed above.
</p>
        <p>
For a generic array of T, you will likely want to provide your own <em>Converter</em> if
T's .ToString() method does not display the information you want to show in the CSV
string. Below is a lame example of a converter. It takes the <em>int</em> value,
converts it to the <em>char</em> value.
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 Converter\cf1 &lt;\cf4 {\b int}\cf1 , \cf4 {\b string}\cf1 &gt; \cf5 converter\cf1  = (\cf5 i\cf1 ) =&gt;\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 {\b return}\cf1  ((\cf4 {\b char}\cf1 )\cf5 i\cf1 ).\cf5 ToString\cf1 ();\par ??\tab \tab \tab \};\par ??\tab \tab \tab \cf5 csv\cf1  = \cf5 array\cf1 .\cf5 ToCsv\cf1 (\cf5 converter\cf1 );}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 72px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span>             <span style="COLOR: #2b91af">Converter</span>&lt;<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span> =
(<span style="COLOR: #dfdfbf">i</span>) =&gt;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span>            
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span> ((<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">char</span>)<span style="COLOR: #dfdfbf">i</span>).<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span>            
};
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">array</span>.<span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">converter</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
I think something so simple, and definitely re-usable, would benefit any developer.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=08b6d0c7-0e40-4390-af14-a4f2f872ff1a" />
      </div>
    </content>
  </entry>
  <entry>
    <title>A Great Quote</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/08/26/AGreatQuote.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,9151494c-7a68-4361-9ece-ea9b7750de18.aspx</id>
    <published>2008-08-25T23:22:03-07:00</published>
    <updated>2008-09-06T20:40:46.167875-07:00</updated>
    <category term="Quotes" label="Quotes" scheme="http://scott.klueppel.net/CategoryView,category,Quotes.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <div style="width: 500px">
          <p>
"Opportunity is missed by most because it is dressed in overalls and looks like work"
</p>
          <div align="right">
            <p>
- Thomas Alva Edison
</p>
          </div>
        </div>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=9151494c-7a68-4361-9ece-ea9b7750de18" />
      </div>
    </content>
  </entry>
  <entry>
    <title>3.5 Service Pack 1 - WCF Enhancement?</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/08/24/35ServicePack1WCFEnhancement.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,01df2e81-97da-4179-a4b0-a7c6178f5599.aspx</id>
    <published>2008-08-23T18:57:49.904875-07:00</published>
    <updated>2008-08-26T19:08:37.936125-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="WCF" label="WCF" scheme="http://scott.klueppel.net/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Our friends at Microsoft may have slipped one in on us. After installing the 3.5 Framework
Service Pack 1, it appears that you no longer need the [DataContract] or [DataMember]
attributes on your DataContracts and DataMembers. I'm not sure what the motivation
was for this "enhancement", but it caused some trouble for me the other day.
</p>
        <p>
For this example I will be using the base project VS2008 gives you when you create
a new WCF Service Library. I am simply adding a NestedType to the CompositeType given
in the base project.
</p>
        <p>
Before installing SP1, having code as it appears below would cause an error during
Metadata Exchange that reads something like "Metadata contains a reference that cannot
be resolved". Notice that <em>CompositeType</em>'s <em>NestedObject</em> is marked
as [DataMember] and also notice that the NestedType class is not marked as [DataContract]
and has no [DataMember] attributes. Adding [DataContract] on <em>NestedType</em> and
[DataMember] on <em>IsVisible</em> will clear this error and everything will work
as expected.  
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;\red200\green145\blue145;}??\fs18 \cf1\cb2\highlight2 \tab [\cf3 DataContract\cf1 ]\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 CompositeType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 boolValue\cf1  = \cf4 {\b true}\cf1 ;\par ??\tab \tab \cf4 {\b string}\cf1  \cf5 stringValue\cf1  = \cf6 "Hello "\cf1 ;\par ??\tab \tab \cf3 NestedType\cf1  \cf5 nestedObject\cf1  = \cf4 {\b new}\cf1  \cf3 NestedType\cf1 ();\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 BoolValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 boolValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 boolValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b string}\cf1  \cf5 StringValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 stringValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 stringValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf3 NestedType\cf1  \cf5 NestedObject\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 nestedObject\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 nestedObject\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}\par ??\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 NestedType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 isVisible\cf1  = \cf4 {\b false}\cf1 ;\par ??\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 IsVisible\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 isVisible\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 isVisible\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}}
-->
        <div style="overflow-y: scroll; font-size: 9pt; background: #3f3f3f; width: 600px; color: #dcdccc; font-family: consolas; height: 200px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   24</span>     [<span style="color: #2b91af">DataContract</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   25</span>     <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">class</span><span style="color: #2b91af">CompositeType</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   26</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   27</span>         <span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">boolValue</span> = <span style="font-weight: bold; color: #e1e18a">true</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   28</span>         <span style="font-weight: bold; color: #e1e18a">string</span><span style="color: #dfdfbf">stringValue</span> = <span style="color: #c89191">"Hello
"</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   29</span>         <span style="color: #2b91af">NestedType</span><span style="color: #dfdfbf">nestedObject</span> = <span style="font-weight: bold; color: #e1e18a">new</span><span style="color: #2b91af">NestedType</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   30</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   31</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   32</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">BoolValue</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   33</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   34</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">boolValue</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   35</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">boolValue</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   36</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   37</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   38</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   39</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">string</span><span style="color: #dfdfbf">StringValue</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   40</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   41</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">stringValue</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   42</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">stringValue</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   43</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   44</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   45</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   46</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="color: #2b91af">NestedType</span><span style="color: #dfdfbf">NestedObject</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   47</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   48</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">nestedObject</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   49</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">nestedObject</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   50</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   51</span>     }
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   52</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   53</span>     <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">class</span><span style="color: #2b91af">NestedType</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   54</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   55</span>         <span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">isVisible</span> = <span style="font-weight: bold; color: #e1e18a">false</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   56</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   57</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">IsVisible</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   58</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   59</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">isVisible</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   60</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">isVisible</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   61</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   62</span>     }
</p>
        </div>
        <p>
 
</p>
        <p>
The same code in use after SP1 will not cause this error. WCF will interpret from <em>CompositeType</em>'s
[DataContract] attribute and <em>NestedObject</em>'s [DataMember] attribute that you
meant to put [DataContract] on <em>NestedType</em>. So what's the big deal, right?
WCF is doing me a solid by guessing at what I meant to do. To me, this violates the
repeated opt-in theme present in WCF. For every other important decision, the developer
must write code to opt-in to a feature. For example, TransactionFlow defaults to false
so we don't use the client's incoming transaction with explicitly writing code that
says to do so. 
</p>
        <p>
This is clearly not on the same level as TransactionFlow. But why does it assume something
about my objects? Why does it assume that every member of my object should be a DataMember?
</p>
        <p>
I noticed this new "feature" when troubleshooting some code that had different namespace
names specified in the DataContract attribute. Since the <em>NestedType</em> did not
have a [DataContract] attribute, the namespace was using the original namespace name.
The equivalent of <em>CompositeType </em>came through correctly, but the <em>NestedObject </em>had
no value.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=01df2e81-97da-4179-a4b0-a7c6178f5599" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Performance = Data Mass x Velocity ^2</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/06/29/PerformanceDataMassXVelocity2.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,f6cca0b0-5d91-48bf-a644-338e2b781d30.aspx</id>
    <published>2008-06-28T21:11:00.658-07:00</published>
    <updated>2008-07-06T20:19:15.653875-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="Database" label="Database" scheme="http://scott.klueppel.net/CategoryView,category,Database.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Enterprise applications store their data in a relational database. Our code reads
the data stored in tables with many complex joins and business rule laden queries.
We take the results of those queries and construct an equally complex business entity
that is used by our application logic. Most developers, myself excluded, hate working
with the database. Writing, modifying, or even seeing T-SQL causes some developers
to itch. LINQ to SQL serves as a partially effective Hydrocortisone to relieve the
itch. But they still need to maintain the schema, write SQL-mindful LINQ queries,
and deal with the constant DataContext updates. 
</p>
        <p>
  
</p>
        <p>
Imagine a world where you no longer need to translate your complex business entities
to and from relational tables.  A world where there is no database backing store.
A world where we create our business entities and store them in memory. Even better,
in memory on a shared resource. Does it sound like an inconceivable futuristic developer
heaven? Well it probably is, but this is really cool stuff in the works. 
</p>
        <p>
  
</p>
        <p>
Enter the Microsoft project code-named "<a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx">Velocity</a>."
The blurb on the overview page reads: 
</p>
        <blockquote>
          <p>
            <font face="Arial Rounded MT Bold" color="#000080" size="2">"Velocity" is a distributed
in-memory application cache platform for developing scalable, high-performance applications.
"Velocity" can be used to cache any CLR object and provides access through simple
APIs. The primary goals for "Velocity" are performance, scalability and availability.</font>
          </p>
        </blockquote>
        <p>
I have been working with the <a href="http://digipede.net">Digipede Network</a>, the
leading grid computing software solution, for a few months. The Velocity architecture
sounds remarkably similar to Digipede's. I have seen the great benefits of the Digipede
Network and have high expectations for Velocity.
</p>
        <p>
The Digipede Network, for those of you that haven't seen it yet, consists of a central
Digipede Server and one or many Digipede Agents. The server receives client requests
and assigns tasks to the agents. The client uses the Digipede API to communicate with
the server. The API pretty much wraps client-to-server and server-to-client WSE2 web
service calls. This architecture allows you to take almost any CPU-intensive process
and spread the workload among tens or hundreds of commodity or server grade machines.
The result is a very high performing and easily scaled system with few code changes
from what you do today. 
</p>
        <p>
Digipede Network Diagram:
</p>
        <p>
          <a href="http://www.digipede.net/products/technology.html" target="_blank">
            <img height="453" alt="Digipede Network Diagram" src="http://www.digipede.net/images/how_it_works.gif" width="518" border="0" />
          </a>
        </p>
        <p>
Digipede only works in this configuration, while <a href="http://msdn.microsoft.com/en-us/library/cc645013.aspx" target="_blank">Velocity
has two proposed deployment models</a>. You can have a "caching tier", similar to
Digipede's Server and Agent configuration, or you can house Velocity as a Caching
Service directly in IIS7. I don't know how communications will be handled between
the client API and the "caching tier", but I assume it will be some sort of service
calls (WCF perhaps). All CLR objects stored in the Velocity cache must be marked [Serializable]
just as task worker classes must be to work with Digipede.
</p>
        <p>
The Velocity API looks simple enough too. It exposes intuitive Get() and Put() methods
where you call the cache by name. I can see how versioning of the cached objects might
get tricky. Your application will also need a new configSection that specifies the
deployment mode, locality, and also contains the list of cache hosts. As this is a
distributed solution, the standard virtual machine playground doesn't work too well
to really test this out.
</p>
        <p>
This looks promising, and I'll be following the progress of the project closely.
</p>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B24C3708-EEFF-4055-A867-19B5851E7CD2" target="_blank">Download
Velocity</a>
        </p>
        <p>
          <a href="http://code.msdn.microsoft.com/velocity" target="_blank">Download the Velocity
CPT 1 samples</a>
        </p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=f6cca0b0-5d91-48bf-a644-338e2b781d30" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Parameter Sniffing in SQL 2005</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/06/22/ParameterSniffingInSQL2005.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,3d7a84f1-e8c6-4e97-ba3d-14a8d332e594.aspx</id>
    <published>2008-06-21T19:24:02.421-07:00</published>
    <updated>2008-06-27T22:29:02.627625-07:00</updated>
    <category term="Database" label="Database" scheme="http://scott.klueppel.net/CategoryView,category,Database.aspx" />
    <category term="SQL" label="SQL" scheme="http://scott.klueppel.net/CategoryView,category,SQL.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A few months after SQL 2005 was released and hit the productions servers, some people
started experiencing some odd behavior in their stored procedures. Simple stored procedures
that normally return in 0 seconds would take upwards of a minute to return. Even more
strange was the fact that the same query, outside of a stored procedure, would still
return in 0 seconds.
</p>
        <p>
It never affected me personally... until today. Three years late to the party. It's
funny how much more interested I am in the causes and solutions for this apparent
problem when it affects me. "Parameter Sniffing" is the term Microsoft uses to describe
the feature that causes this odd behavior. While it appeared as an issue when I encountered
it today, I found that the feature is not only well-intentioned but quite useful.
</p>
        <p>
The execution plan is generated and cached the first time your stored procedure is
called. When the execution plan is being created, SQL Server reads the input parameters
and uses them to optimize the execution plan for those parameters. This is called
"parameter sniffing." If the input parameters used in the first call to the stored
procedure are atypical for the overall use of the stored procedure, a less than ideal
execution plan will be cached for all subsequent calls.
</p>
        <p>
Simply dropping and recompiling the stored procedure does not seem to affect the cached
execution plan. Updating statistics on the tables used in the stored procedure will
cause the execution plan to be regenerated on the next call of the stored procedure.
However, if the same or similar atypical parameters are used on the first execution
of the stored procedure, an equally sub-optimal execution plan will be cached.
</p>
        <p>
You can turn off parameter sniffing. This is accomplished by assigning the input parameter
values to local variables inside the stored procedure and then using the local variables
within the stored procedure. When the execution plan is created, SQL Server will look
at the table statistics to optimize the query for the "average" use. It does this
by looking at the tables used in the query and analyzing row counts, etc. to find
a reasonable plan that will likely suit a majority of situations.
</p>
        <p>
My stored procedure was bringing back multiple resultsets to be used to create a hierarchical
structure in code. It works essentially like the following:
</p>
        <p>
          <font color="#003300">
            <font color="#0000ff">CREATE PROCEDURE</font> [dbo].[usp_Order_GetOrderDetails] 
<br />
( 
<br />
   @StartOrderId <font color="#0000ff">INT</font>, 
<br />
   @EndOrderId <font color="#0000ff">INT</font><br />
) 
<br /><font color="#0000ff">AS 
<br />
BEGIN</font><br />
   <font color="#0000ff">SELECT</font> * 
<br />
   <font color="#0000ff">FROM</font> Order 
<br />
   <font color="#0000ff">WHERE</font> OrderId <font color="#a9a9a9">BETWEEN</font> @StartOrderId <font color="#a9a9a9">AND</font> @EndOrderId 
<br />
  
<br />
   <font color="#0000ff">SELECT</font> * 
<br />
   <font color="#0000ff">FROM</font> OrderLineItem 
<br />
   <font color="#0000ff">WHERE</font> OrderId <font color="#a9a9a9">BETWEEN</font> @StartOrderId <font color="#a9a9a9">AND</font> @EndOrderId 
<br /></font>
          <font color="#0000ff">END</font>
        </p>
        <p>
I was testing the stored procedure for full day using the same ID for @StartOrderId
and @EndOrderId. Since the intended use of this stored procedure is almost always
@EndOrderId = @StartOrderId + 1000, this makes a big difference when calculating the
estimate number of rows returned. I forced SQL Server to assume that my execution
plan should be based on an ID range of 1 instead of 1000. Turning off parameter sniffing
lessens these effects.
</p>
        <p>
To turn off parameter sniffing, it would look like this:
</p>
        <p>
          <font color="#0000ff">CREATE PROCEDURE</font> [dbo].[usp_Order_GetOrderDetails] 
<br />
( 
<br />
   @StartOrderId <font color="#0000ff">INT</font>, 
<br />
   @EndOrderId <font color="#0000ff">INT</font><br />
) 
<br /><font color="#0000ff">AS 
<br />
BEGIN 
<br />
   DECLARE <font color="#000000">@Start</font> INT 
<br />
   DECLARE <font color="#000000">@End</font> INT 
<br />
   SET <font color="#000000">@Start = @StartOrderId</font><br />
   SET <font color="#000000">@End = @EndOrderId</font><br />
 </font><br />
   <font color="#0000ff">SELECT</font> * 
<br />
   <font color="#0000ff">FROM</font> Order 
<br />
   <font color="#0000ff">WHERE</font> OrderId <font color="#a9a9a9">BETWEEN</font> @Start <font color="#a9a9a9">AND</font> @End 
<br />
  
<br />
   <font color="#0000ff">SELECT</font> * 
<br />
   <font color="#0000ff">FROM</font> OrderLineItem 
<br />
   <font color="#0000ff">WHERE</font> OrderId <font color="#a9a9a9">BETWEEN</font> @Start <font color="#a9a9a9">AND</font> @End 
<br /><font color="#0000ff">END</font></p>
        <p>
This immediately improved the performance of my stored procedure. The time to complete
reduced from ~2 minutes to ~2 seconds for my typical 1000 ID range (I know 2 seconds
is a lot, but these tables have millions and millions of rows). But only one piece
of code in the application calls this stored procedure, and 99 out of 100 times it
will have a range of 1000 IDs. Why would I want SQL Server to guess how many Orders
I will typically bring back when I know the exact number? 
</p>
        <p>
I should have the optimal execution plan if I update statistics on Order and OrderLineItem,
and then call usp_Order_GetOrderDetails 1, 1000 after I compile this stored procedure.
This sounds like a lot of work to me, and I did not notice any performance boost by
doing this. I chose to leave parameter sniffing off. 
</p>
        <p>
The only drawbacks to turning off parameter sniffing is the weird looking SQL and
the inevitable questions during code review about the crazy input parameter to variable
mapping. But when you school the doubters on the causes and effects of parameter sniffing,
it will put another notch in your guru stick.
</p>
        <p>
From what I have read, this was not a new feature in SQL 2005. I can't, however, find
any mention of it in SQL 2000 books online, and this feature never showed its face
in SQL 2000.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=3d7a84f1-e8c6-4e97-ba3d-14a8d332e594" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Service Trace Viewer</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/06/19/ServiceTraceViewer.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,0c636536-67bd-4395-849c-5554c1ee20f2.aspx</id>
    <published>2008-06-18T19:23:30.026-07:00</published>
    <updated>2008-06-27T21:52:36.625-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="Dev Tools" label="Dev Tools" scheme="http://scott.klueppel.net/CategoryView,category,DevTools.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://scott.klueppel.net/CategoryView,category,VisualStudio.aspx" />
    <category term="WCF" label="WCF" scheme="http://scott.klueppel.net/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Juval Löwy mentioned the <a href="http://msdn.microsoft.com/en-us/library/ms732023.aspx">Microsoft
Service Trace Viewer</a> in a <a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032379028&amp;EventCategory=5&amp;culture=en-US&amp;CountryCode=US">webcast</a> today.
If you ever wondered exactly what WCF does under all of those covers, check this out.
</p>
        <p>
First things first. Enable tracing on the client and host applications using the WCF
Configuration Editor. Enable the verbose trace level and check all of the listener
settings. This will add all of the necessary &lt;system.diagnostics&gt; settings in
your config file. The next time you start each of the applications, a .svclog file
will be created that will be used by the Service Trace Viewer.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/EditWCFConfigTracing.png" border="0" />
        </p>
        <p>
Start your host, start your client, run through the test cases that you want to analyze
in the viewer. After your test run is complete, open the viewer, located at C:\Program
Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe. "Open" the host.svclog
file, and then "Add" the client.svclog file. Both "Open" and "Add" are menu items
under "File".
</p>
        <p>
Start on the Activity tab, look through the host and client activities that occurred.
Everything from ServiceHost construction through ServiceHost closing shows up. This
is very cool, especially when analyzing the differences between different security,
session, and reliability settings.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/SVTActivityTab.png" border="0" />
        </p>
        <p>
When you are done looking through the activities, check out the Graph tab. Here you
can look at the interactions between the client and host, as well as looking at the
details of each activity (at the top right). At the bottom right, you will also notice
the formatted and xml details of this activity.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/STV.png" border="0" />
        </p>
        <p>
This is a very cool tool for both debugging and training. Below is my lame test projects,
if you want to skip past the configuration and check out the tool. My .svclog files
are located in the Client and Host folders.
</p>
        <p>
          <a href="http://gotjeep.net/Blogs/content/binary/SvtTest.zip">SvtTest.zip (190.32
KB)</a>
        </p>
        <p>
Enjoy! Thanks to Juval for the direction.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=0c636536-67bd-4395-849c-5554c1ee20f2" />
      </div>
    </content>
  </entry>
  <entry>
    <title>My VS2005 and VS2008 themes</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/06/19/MyVS2005AndVS2008Themes.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,9a4ba1c7-b29f-40ca-a6d8-d8795e06e23f.aspx</id>
    <published>2008-06-18T18:44:39.838-07:00</published>
    <updated>2008-06-19T18:09:55.963625-07:00</updated>
    <category term="Visual Studio" label="Visual Studio" scheme="http://scott.klueppel.net/CategoryView,category,VisualStudio.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I couldn't take the X-Files-esque output window anymore. Here are my spinoffs of the <a href="http://idehotornot.ning.com/index.php/index/show?id=2353062">ZenBurn</a> (<a href="http://gotjeep.net/Blogs/PermaLink,guid,3deae2d5-50a2-4435-ab7c-e9d1e240e8ff.aspx">recently
posted as ScottGu's</a>) theme.
</p>
        <p>
          <a href="http://gotjeep.net/Blogs/content/binary/VSSettings1.zip">VSSettings1.zip
(118.09 KB)</a>
        </p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=9a4ba1c7-b29f-40ca-a6d8-d8795e06e23f" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ScottGu VS 2008 Theme</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/05/30/ScottGuVS2008Theme.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,3deae2d5-50a2-4435-ab7c-e9d1e240e8ff.aspx</id>
    <published>2008-05-29T19:21:53.9-07:00</published>
    <updated>2008-06-27T21:53:36.3125-07:00</updated>
    <category term="Dev Tools" label="Dev Tools" scheme="http://scott.klueppel.net/CategoryView,category,DevTools.aspx" />
    <category term="Visual Studio" label="Visual Studio" scheme="http://scott.klueppel.net/CategoryView,category,VisualStudio.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been using ScottGu's Visual Studio 2008 theme for the last few weeks and love
it. You can see it <a href="http://www.scottgu.com/blogposts/mvc3announce/step11.png">here</a> and
download it <a href="http://www.scottgu.com/blogposts/aprilmvc/scottgu-dark.zip">here</a>.
</p>
        <img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=3deae2d5-50a2-4435-ab7c-e9d1e240e8ff" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Calling services from services</title>
    <link rel="alternate" type="text/html" href="http://scott.klueppel.net/2008/03/27/CallingServicesFromServices.aspx" />
    <id>http://scott.klueppel.net/PermaLink,guid,60081b96-9f12-47f4-a102-ef220b2abc79.aspx</id>
    <published>2008-03-26T19:08:46.182-07:00</published>
    <updated>2008-06-08T18:54:53.956-07:00</updated>
    <category term=".NET Framework" label=".NET Framework" scheme="http://scott.klueppel.net/CategoryView,category,NETFramework.aspx" />
    <category term="C#" label="C#" scheme="http://scott.klueppel.net/CategoryView,category,C.aspx" />
    <category term="WCF" label="WCF" scheme="http://scott.klueppel.net/CategoryView,category,WCF.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was looking for guidance on this topic, and came up with nothing. I'm sure people
are doing this, but can't find any info. For anyone looking like I was, here's how
to do it.
</p>
        <p>
It's much simpler than I imagined, thanks to WCF. You can programmatically create
your endpoint, binding, and channel inside your service. This would require that the
address be hard-coded and require a recompile to change the address or binding. As
long as your host's app.config or web.config has a client endpoint specifying the
contract, you don't have to go through all that work. Your service is simply a client
of another service, so your code looks just like that of a client of your service.
Furthermore, changing the address or binding is as simple as changing config file
values.
</p>
        <p>
Service code:<br /><br /></p>
        <div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px">
          <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">using</span> System;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">using</span> System.ServiceModel;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue">using</span> DataContracts;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue">namespace</span> ServiceImplementation
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    5</span> {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    6</span>    
[<span style="COLOR: #2b91af">ServiceContract</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    7</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: #2b91af">IEmailService</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    8</span>    
{
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    9</span>    
    [<span style="COLOR: #2b91af">OperationContract</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   10</span>         <span style="COLOR: blue">void</span> Send(DataContracts.<span style="COLOR: #2b91af">MailMessage</span> msg);
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   11</span>     }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   12</span> 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   13</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">EmailService</span> : <span style="COLOR: #2b91af">IEmailService</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   14</span>     {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   15</span>        
[<span style="COLOR: #2b91af">OperationBehavior</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   16</span>         <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> Send(DataContracts.<span style="COLOR: #2b91af">MailMessage</span> msg)
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   17</span>        
{
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   18</span>        
    <span style="COLOR: green">// Open client proxy for legacy web
service</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   19</span>        
    <span style="COLOR: blue">using</span> (<span style="COLOR: #2b91af">LegacyEmailServiceClient</span> proxy
=
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   20</span>        
        <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">LegacyEmailServiceClient</span>())
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   21</span>        
    {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   22</span>        
        proxy.SendEmail(msg.To, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   23</span>        
            msg.CC, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   24</span>        
            msg.Bcc, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   25</span>        
            msg.Body, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   26</span>        
            msg.Attachments);
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   27</span>        
    }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   28</span>        
}
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   29</span>     }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   30</span> }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   31</span> 
</p>
          </div>
          <!--EndFragment-->
        </div>
        <br />
        <br />
Host's app.config:<br /><br /><div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px"><div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">&lt;?</span><span style="COLOR: #a31515">xml</span><span style="COLOR: blue"></span><span style="COLOR: red">version</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">1.0</span>"<span style="COLOR: blue"></span><span style="COLOR: red">encoding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">utf-8</span>"<span style="COLOR: blue">?&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">&lt;</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue"> 
&lt;</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    5</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    6</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    7</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">security</span><span style="COLOR: blue"></span><span style="COLOR: red">mode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">None</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    8</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    9</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   10</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">netTcpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   11</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_Common</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   12</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">security</span><span style="COLOR: blue"></span><span style="COLOR: red">mode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">None</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   13</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   14</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">netTcpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   15</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   16</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   17</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">address</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://www.gotjeep.net/legacy/email.asmx</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   18</span> <span style="COLOR: blue"> 
        </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">basicHttpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   19</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   20</span> <span style="COLOR: blue"> 
        </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LegacyEmailServiceClient</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   21</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LegacyEmailServiceClient</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   22</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   23</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">services</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   24</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">service</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   25</span> <span style="COLOR: blue"> 
            </span><span style="COLOR: red">behaviorConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">returnFaults</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   26</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">host</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   27</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">baseAddresses</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   28</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">add</span><span style="COLOR: blue"></span><span style="COLOR: red">baseAddress</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://localhost:8080/EmailService</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   29</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">add</span><span style="COLOR: blue"></span><span style="COLOR: red">baseAddress</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">net.tcp://localhost:8088/EmailService</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   30</span> <span style="COLOR: blue"> 
        &lt;/</span><span style="COLOR: #a31515">baseAddresses</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   31</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">host</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   32</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   33</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">netTcpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   34</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   35</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.IEmailService</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   36</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   37</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">basicHttpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   38</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   39</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.IEmailService</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   40</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">service</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   41</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">services</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   42</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">behaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   43</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">serviceBehaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   44</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">behavior</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">returnFaults</span>"<span style="COLOR: blue"> &gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   45</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">serviceMetadata</span><span style="COLOR: blue"></span><span style="COLOR: red">httpGetEnabled</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   46</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">behavior</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   47</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">serviceBehaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   48</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">behaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   49</span> <span style="COLOR: blue"> 
&lt;/</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   50</span> <span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p></div><!--EndFragment--></div><p></p><img width="0" height="0" src="http://scott.klueppel.net/aggbug.ashx?id=60081b96-9f12-47f4-a102-ef220b2abc79" /></div>
    </content>
  </entry>
</feed>