<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>DotNetDrop</title>
	<atom:link href="http://www.dotnetdrop.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dotnetdrop.com</link>
	<description>C#, WPF, Silverlight, Asp.Net Mvc, whatever else I feel like.</description>
	<pubDate>Tue, 03 Nov 2009 18:59:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Table value parameters with Enterprise Library Data Access Application Block</title>
		<link>http://www.dotnetdrop.com/table-value-parameters-with-enterprise-library-data-access-application-block/</link>
		<comments>http://www.dotnetdrop.com/table-value-parameters-with-enterprise-library-data-access-application-block/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 18:59:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HowTo]]></category>

		<category><![CDATA[Enterprise Library]]></category>

		<category><![CDATA[Sql]]></category>

		<guid isPermaLink="false">http://www.dotnetdrop.com/?p=38</guid>
		<description><![CDATA[I wasn&#8217;t finding much with a quick search for enterprise library table value parameters or data access application block table value parameters. After a bit of research I discovered that versions ]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t finding much with a quick search for enterprise library table value parameters or data access application block table value parameters. After a bit of research I discovered that versions <= 4.1 don't support tvps as well as I'd hoped. The key is you must cast (or create) a SqlDatabase and use SqlDbType.Structured. This will break your database independent code. The easiest way I see to use table parameters is create a DataTable and add columns to match the parameter. The column names of this table do not matter.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">            DataTable table <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataTable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            table.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> DataColumn<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;ID&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            table.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> DataColumn<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Value&quot;</span>, <span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            table.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> <span style="color: #FF0000;">object</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#123;</span> ID, value <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            SqlDatabase database <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>SqlDatabase<span style="color: #000000;">&#41;</span>DatabaseFactory.<span style="color: #0000FF;">CreateDatabase</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;DatabaseName&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            DbCommand dbCommand <span style="color: #008000;">=</span> database.<span style="color: #0000FF;">GetStoredProcCommand</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;[StoredProcName]&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            database.<span style="color: #0000FF;">AddInParameter</span><span style="color: #000000;">&#40;</span>dbCommand, <span style="color: #666666;">&quot;@MyTableValueParameter&quot;</span>, SqlDbType.<span style="color: #0000FF;">Structured</span>, table<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>IDataReader reader <span style="color: #008000;">=</span> database.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span>dbCommand<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            ...</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dotnetdrop.com/table-value-parameters-with-enterprise-library-data-access-application-block/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WPF/Silverlight named color chart table thingie</title>
		<link>http://www.dotnetdrop.com/wpfsilverlight-named-color-chart-table-thingie/</link>
		<comments>http://www.dotnetdrop.com/wpfsilverlight-named-color-chart-table-thingie/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 19:51:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.dotnetdrop.com/?p=27</guid>
		<description><![CDATA[I ran across a color chart for the named colors the other day while searching for something wpf related. It took me too long to find it today. The next time I&#8217;m digging around in my xaml for a background color and see BlanchedAlmond I&#8217;ll have a reference.
from:
http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush.color(VS.95).aspx
]]></description>
			<content:encoded><![CDATA[<p>I ran across a color chart for the named colors the other day while searching for something wpf related. It took me too long to find it today. The next time I&#8217;m digging around in my xaml for a background color and see BlanchedAlmond I&#8217;ll have a reference.</p>
<div id="attachment_28" class="wp-caption alignnone" style="width: 652px"><img class="size-full wp-image-28" title="Wpf Silverlight System Color Chart Table" src="http://www.dotnetdrop.com/wp-content/uploads/2009/04/wpf_silverlight_system_color_chart.png" alt="Wpf Silverlight System Color Chart Table" width="642" height="895" /><p class="wp-caption-text">Wpf Silverlight System Color Chart Table</p></div>
<p>from:</p>
<p><a title="http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush.color(VS.95).aspx" href="http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush.color(VS.95).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush.color(VS.95).aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetdrop.com/wpfsilverlight-named-color-chart-table-thingie/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Json serialization of PaginatedList does not include list properties</title>
		<link>http://www.dotnetdrop.com/json-serialization-of-paginatedlist-does-not-include-list-properties/</link>
		<comments>http://www.dotnetdrop.com/json-serialization-of-paginatedlist-does-not-include-list-properties/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 05:30:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Mvc]]></category>

		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.dotnetdrop.com/?p=15</guid>
		<description><![CDATA[Lately I&#8217;ve been playing around with Asp.Net Mvc. I&#8217;m trying to adapt the NerdDinner sample for a project I&#8217;m working on. The sample includes a class called PaginatedList&#60;T&#62;.  PaginatedList&#60;T&#62; looks something like this:

   public class PaginatedList&#60;T&#62; : List&#60;T&#62;
   &#123;
        public int PageIndex  &#123; [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been playing around with Asp.Net Mvc. I&#8217;m trying to adapt the NerdDinner sample for a project I&#8217;m working on. The sample includes a class called PaginatedList&lt;T&gt;.  PaginatedList&lt;T&gt; looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">   <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> PaginatedList<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> <span style="color: #008000;">:</span> List<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span>
   <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> PageIndex  <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF;">private</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> PageSize   <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF;">private</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> TotalCount <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF;">private</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> TotalPages <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> <span style="color: #0600FF;">private</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span></pre></div></div>

<p>My controller method looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">   <span style="color: #0600FF;">public</span> ActionResult FindBusinessesByName<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> businessName, <span style="color: #FF0000;">int</span> limit, <span style="color: #FF0000;">int</span> page<span style="color: #000000;">&#41;</span>
   <span style="color: #000000;">&#123;</span>
      BusinessRepository repository <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BusinessRepository<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
      PaginatedList<span style="color: #008000;">&lt;</span>Business<span style="color: #008000;">&gt;</span> paginatedBusinesses <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PaginatedList<span style="color: #008000;">&lt;</span>Business<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>repository.<span style="color: #0000FF;">FindBusinessesByName</span><span style="color: #000000;">&#40;</span>businessName<span style="color: #000000;">&#41;</span>, page, limit<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
      <span style="color: #0600FF;">return</span> Json<span style="color: #000000;">&#40;</span>paginatedBusinesses<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
   <span style="color: #000000;">&#125;</span></pre></div></div>

<p>I&#8217;m using jQuery to get a PaginatedList of businesses from my controller. I use the list of businesses to create an unordered list to display the business information. I haven&#8217;t played with jQuery or json serialization much so I was surprised to see that only the business data was returned. The extra properties on the PaginatedList were not. I dug around a bit and downloaded the newly released source for Mvc (woot!). I found the two lines in JsonResult.cs that do the serialization:<br />
<span id="more-15"></span></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">                JavaScriptSerializer serializer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> JavaScriptSerializer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>serializer.<span style="color: #0000FF;">Serialize</span><span style="color: #000000;">&#40;</span>Data<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>A quick search for JavaScriptSerializer shows that List&lt;T&gt; becomes an &#8220;Array that uses JSON array syntax&#8221;. So it appears that since PaginatedList&lt;T&gt; derives from List&lt;T&gt; the serializer ignores the properties on the PaginatedList.</p>
<p>I was able to work around this by changing my controller method to this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">public</span> ActionResult FindBusinessesByName<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> businessName, <span style="color: #FF0000;">int</span> limit, <span style="color: #FF0000;">int</span> page<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            BusinessRepository repository <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BusinessRepository<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            PaginatedList<span style="color: #008000;">&lt;</span>Business<span style="color: #008000;">&gt;</span> paginatedBusinesses <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> PaginatedList<span style="color: #008000;">&lt;</span>Business<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span>repository.<span style="color: #0000FF;">FindBusinessesByName</span><span style="color: #000000;">&#40;</span>businessName<span style="color: #000000;">&#41;</span>, page, limit<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            var paginationContainer <span style="color: #008000;">=</span> <span style="color: #008000;">new</span>
            <span style="color: #000000;">&#123;</span>
                PageIndex <span style="color: #008000;">=</span> paginatedBusinesses.<span style="color: #0000FF;">PageIndex</span>,
                PageSize <span style="color: #008000;">=</span> paginatedBusinesses.<span style="color: #0000FF;">PageSize</span>,
                TotalCount <span style="color: #008000;">=</span> paginatedBusinesses.<span style="color: #0000FF;">TotalCount</span>,
                TotalPages <span style="color: #008000;">=</span> paginatedBusinesses.<span style="color: #0000FF;">TotalPages</span>,
                Businesses <span style="color: #008000;">=</span> paginatedBusinesses
            <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">return</span> Json<span style="color: #000000;">&#40;</span>paginationContainer<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.dotnetdrop.com/json-serialization-of-paginatedlist-does-not-include-list-properties/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Error generating MVC view for Entity Framework model</title>
		<link>http://www.dotnetdrop.com/error-generating-mvc-view-for-entity-framework-model/</link>
		<comments>http://www.dotnetdrop.com/error-generating-mvc-view-for-entity-framework-model/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 22:22:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[Error]]></category>

		<category><![CDATA[Mvc]]></category>

		<guid isPermaLink="false">http://www.dotnetdrop.com/?p=5</guid>
		<description><![CDATA[I&#8217;m trying to generate  a view for Asp.Net MVC 1.0 using an Entity Framework model. This is from Details.tt.  Anyone seen this error?
I get this the first time I try to generate:
error CS0234: Compiling transformation: The type or namespace name &#8216;Data&#8217; does not exist in the namespace &#8216;System&#8217; (are you missing an assembly reference?)

And if [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to generate  a view for Asp.Net MVC 1.0 using an Entity Framework model. This is from Details.tt.  Anyone seen this error?</p>
<p>I get this the first time I try to generate:</p>
<p>error CS0234: Compiling transformation: The type or namespace name &#8216;Data&#8217; does not exist in the namespace &#8216;System&#8217; (are you missing an assembly reference?)</p>
<p><span id="more-5"></span></p>
<p>And if I try to generate again:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Template Processing resulted in 2 Errors<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates\AddView\Details.tt(-1,-1) : error : The host threw an exception while trying to resolve the assembly reference &#8216;System.Data.Entity&#8217;. The transformation will not be run. The following Exception was thrown:</p>
<p>System.ArgumentOutOfRangeException: Length cannot be less than zero.</p>
<p>Parameter name: length</p>
<p>at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)</p>
<p>at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)</p>
<p>at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection)</p>
<p>at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection)</p>
<p>at System.Reflection.Assembly.Load(String assemblyString)</p>
<p>at Microsoft.VisualStudio.Web.Mvc.MvcTextTemplateHost.Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ResolveAssemblyReference(String assemblyReference)</p>
<p>at Microsoft.VisualStudio.TextTemplating.Engine.CompileAndRunCode(String generatorCode, ITextTemplatingEngineHost host, TemplateProcessingSession session)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dotnetdrop.com/error-generating-mvc-view-for-entity-framework-model/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
