<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nPath Ltd. &#187; Linq</title>
	<atom:link href="http://www.npathweb.com/tag/linq/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.npathweb.com</link>
	<description>Web Development Blog</description>
	<lastBuildDate>Mon, 22 Feb 2010 15:16:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Copy a generic list, List, by ref, by value wierdness</title>
		<link>http://www.npathweb.com/2009/10/19/copy-a-generic-list-list-by-ref-by-value-wierdness/</link>
		<comments>http://www.npathweb.com/2009/10/19/copy-a-generic-list-list-by-ref-by-value-wierdness/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 17:45:00 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Linq]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/?p=100</guid>
		<description><![CDATA[Here is my latest weird problem.
I had a generic list, I wanted to  make a copy of it. So the aproach I used was to make the new list = the first one.
Enter the wierdness; any mods to the second list showed up in the first one. So I guess it used a pointer or [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my latest weird problem.</p>
<p>I had a generic list, I wanted to  make a copy of it. So the aproach I used was to make the new list = the first one.</p>
<p>Enter the wierdness; any mods to the second list showed up in the first one. So I guess it used a pointer or passed it by reference instead of  making a copy like I expected.</p>
<p>Live and learn I guess. The work around was to initialize it blank and call the add range function passing it the first list.</p>
<p>Here is an example of what I&#8217;m talking about. You can past this into Linqpad as C# Statements and play around more.</p>
<p><!--</p>
<p>p.MsoNormal<br />
{margin-top:0in;<br />
margin-right:0in;<br />
margin-bottom:10.0pt;<br />
margin-left:0in;<br />
line-height:115%;<br />
font-size:11.0pt;<br />
font-family:"Calibri","sans-serif";<br />
}<br />
table.MsoNormalTable<br />
{line-height:115%;<br />
font-size:11.0pt;<br />
font-family:"Calibri","sans-serif";<br />
}<br />
--></p>
<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt; mso-border-bottom-alt:solid windowtext .75pt;padding:0in 0in 1.0pt 0in">
<p class="MsoNormal" style="border:none;mso-border-bottom-alt:solid windowtext .75pt; padding:0in;mso-padding-alt:0in 0in 1.0pt 0in"><span style="font-size:10.0pt; line-height:115%;font-family:Consolas;color:black">List&lt;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:blue">string</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">&gt; s1 = </span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:blue">new</span><span style="font-size:10.0pt;line-height:115%; font-family:Consolas;color:black"> List&lt;</span><span style="font-size:10.0pt; line-height:115%;font-family:Consolas;color:blue">string</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">&gt;{</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:#DC1414">&#8220;one&#8221;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">,</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:#DC1414">&#8220;two&#8221;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">,</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:#DC1414">&#8220;three&#8221;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">,</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:#DC1414">&#8220;four&#8221;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">,</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:#DC1414">&#8220;five&#8221;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">};</span></p>
<p>List&lt;<span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:blue">string</span><span style="font-size:10.0pt;line-height:115%; font-family:Consolas;color:black">&gt; s2 = s1;</span></p>
<p>s2.Add(<span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:#DC1414">&#8220;six&#8221;</span><span style="font-size:10.0pt;line-height: 115%;font-family:Consolas;color:black">);</p>
<p>s2.Add(</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:#DC1414">&#8220;seven&#8221;</span><span style="font-size:10.0pt; line-height:115%;font-family:Consolas;color:black">);</span></p>
<p>s1.Dump();</p>
<p>s2.Dump();<br />
List&lt;<span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:blue">string</span><span style="font-size:10.0pt;line-height:115%; font-family:Consolas;color:black">&gt; s3 = </span><span style="font-size:10.0pt; line-height:115%;font-family:Consolas;color:blue">new </span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas;color:black">List&lt;</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:blue">string</span><span style="font-size:10.0pt;line-height:115%; font-family:Consolas;color:black">&gt;{};</p>
<p>s3.AddRange(s1);</span></p>
<p>s3.Add(<span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:#DC1414">&#8220;eight&#8221;</span><span style="font-size:10.0pt; line-height:115%;font-family:Consolas;color:black">);</p>
<p>s3.Add(</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:#DC1414">&#8220;nine&#8221;</span><span style="font-size:10.0pt;line-height: 115%;font-family:Consolas;color:black">);</p>
<p>s3.Add(</span><span style="font-size:10.0pt;line-height:115%;font-family:Consolas; color:#DC1414">&#8220;ten&#8221;</span><span style="font-size:10.0pt;line-height: 115%;font-family:Consolas;color:black">);</span></p>
<p>s1.Dump();</p>
<p>s3.Dump();</p></div>
<p class="MsoNormal"><span style="font-size:10.0pt;line-height:115%;font-family: Consolas;color:black">Returns:</span></p>
<table class="MsoNormalTable" style="margin-left:2.4pt;border-collapse:collapse;border:none;mso-border-alt:  solid #1177BB 1.0pt;mso-border-top-alt:solid #1177BB .5pt;mso-yfti-tbllook:  1184" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes">
<td style="border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .5pt; background: #1177BB; padding: 0in 2.4pt 1.2pt 1.2pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><strong><br />
<span style="font-size:8.5pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;color:white"><br />
<span style="mso-field-code:&quot; HYPERLINK \0022\0022 &quot;"><span style="text-decoration: underline;"><br />
<span style="mso-bidi-font-size:   11.0pt;font-family:Webdings;color:blue">5</span><span style="mso-bidi-font-size:11.0pt;color:blue">List&lt;String&gt; (7 items)</span></span></span><br />
</span></strong></td>
</tr>
<tr style="mso-yfti-irow:1">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
one</span></td>
</tr>
<tr style="mso-yfti-irow:2">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
two</span></td>
</tr>
<tr style="mso-yfti-irow:3">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
three</span></td>
</tr>
<tr style="mso-yfti-irow:4">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
four</span></td>
</tr>
<tr style="mso-yfti-irow:5">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
five</span></td>
</tr>
<tr style="mso-yfti-irow:6">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
six</span></td>
</tr>
<tr style="mso-yfti-irow:7">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
seven</span></td>
</tr>
<tr style="mso-yfti-irow:8">
<td style="border: solid #AAAAAA 1.0pt; border-top: none; mso-border-top-alt: solid #AAAAAA .5pt; mso-border-alt: solid #AAAAAA .5pt; background: #1177BB; padding: 0in 2.4pt 1.2pt 1.2pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><strong><br />
<span style="font-size:8.5pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;color:white"><br />
<span style="mso-field-code:&quot; HYPERLINK \0022\0022 &quot;"><span style="text-decoration: underline;"><br />
<span style="mso-bidi-font-size:   11.0pt;font-family:Webdings;color:blue">5</span><span style="mso-bidi-font-size:11.0pt;color:blue">List&lt;String&gt; (7 items)</span></span></span><br />
</span></strong></td>
</tr>
<tr style="mso-yfti-irow:9">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
one</span></td>
</tr>
<tr style="mso-yfti-irow:10">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
two</span></td>
</tr>
<tr style="mso-yfti-irow:11">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
three</span></td>
</tr>
<tr style="mso-yfti-irow:12">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
four</span></td>
</tr>
<tr style="mso-yfti-irow:13">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
five</span></td>
</tr>
<tr style="mso-yfti-irow:14">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
six</span></td>
</tr>
<tr style="mso-yfti-irow:15;mso-yfti-lastrow:yes">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
seven</span></td>
</tr>
</tbody>
</table>
<p class="MsoNormal" style="margin-bottom:.1in;line-height:normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;mso-fareast-font-family: &quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;;display:none; mso-hide:all"> </span></p>
<table class="MsoNormalTable" style="margin-left:2.4pt;border-collapse:collapse;border:none;mso-border-alt:  solid #1177BB 1.0pt;mso-border-top-alt:solid #1177BB .5pt;mso-yfti-tbllook:  1184" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr style="mso-yfti-irow:0;mso-yfti-firstrow:yes">
<td style="border: solid #AAAAAA 1.0pt; mso-border-alt: solid #AAAAAA .5pt; background: #1177BB; padding: 0in 2.4pt 1.2pt 1.2pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><strong><br />
<span style="font-size:8.5pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;color:white"><br />
<span style="mso-field-code:&quot; HYPERLINK \0022\0022 &quot;"><span style="text-decoration: underline;"><br />
<span style="mso-bidi-font-size:   11.0pt;font-family:Webdings;color:blue">5</span><span style="mso-bidi-font-size:11.0pt;color:blue">List&lt;String&gt; (7 items)</span></span></span><br />
</span></strong></td>
</tr>
<tr style="mso-yfti-irow:1">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
one</span></td>
</tr>
<tr style="mso-yfti-irow:2">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
two</span></td>
</tr>
<tr style="mso-yfti-irow:3">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
three</span></td>
</tr>
<tr style="mso-yfti-irow:4">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
four</span></td>
</tr>
<tr style="mso-yfti-irow:5">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
five</span></td>
</tr>
<tr style="mso-yfti-irow:6">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
six</span></td>
</tr>
<tr style="mso-yfti-irow:7">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
seven</span></td>
</tr>
<tr style="mso-yfti-irow:8">
<td style="border: solid #AAAAAA 1.0pt; border-top: none; mso-border-top-alt: solid #AAAAAA .5pt; mso-border-alt: solid #AAAAAA .5pt; background: #1177BB; padding: 0in 2.4pt 1.2pt 1.2pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><strong><br />
<span style="font-size:8.5pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;color:white"><br />
<span style="mso-field-code:&quot; HYPERLINK \0022\0022 &quot;"><span style="text-decoration: underline;"><br />
<span style="mso-bidi-font-size:   11.0pt;font-family:Webdings;color:blue">5</span><span style="mso-bidi-font-size:11.0pt;color:blue">List&lt;String&gt; (10 items)</span></span></span><br />
</span></strong></td>
</tr>
<tr style="mso-yfti-irow:9">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
one</span></td>
</tr>
<tr style="mso-yfti-irow:10">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
two</span></td>
</tr>
<tr style="mso-yfti-irow:11">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
three</span></td>
</tr>
<tr style="mso-yfti-irow:12">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
four</span></td>
</tr>
<tr style="mso-yfti-irow:13">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
five</span></td>
</tr>
<tr style="mso-yfti-irow:14">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
six</span></td>
</tr>
<tr style="mso-yfti-irow:15">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
seven</span></td>
</tr>
<tr style="mso-yfti-irow:16">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
eight</span></td>
</tr>
<tr style="mso-yfti-irow:17">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
nine</span></td>
</tr>
<tr style="mso-yfti-irow:18;mso-yfti-lastrow:yes">
<td style="border:solid #AAAAAA 1.0pt;border-top:none;mso-border-top-alt:   solid #AAAAAA .5pt;mso-border-alt:solid #AAAAAA .5pt;padding:1.2pt 2.4pt 1.2pt 2.4pt" valign="top">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:   normal"><span style="font-size:9.5pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;   mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;"><br />
ten</span></td>
</tr>
</tbody>
</table>
<p class="MsoNormal">
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/10/19/copy-a-generic-list-list-by-ref-by-value-wierdness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insert with FormView using Linq</title>
		<link>http://www.npathweb.com/2009/02/05/insert-with-formview-using-linq/</link>
		<comments>http://www.npathweb.com/2009/02/05/insert-with-formview-using-linq/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 17:05:40 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[Formview]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[VB.Net]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/blog/?p=23</guid>
		<description><![CDATA[I had a wierd error trying to insert data using a formview today.
The jist is this: the formview was trying to use an empty string for an int field instead of Nothing.
Here is the error I saw, helpful huh?

Failed to set one or more properties on type xxxxxxx  Ensure that the input values are valid and can [...]]]></description>
			<content:encoded><![CDATA[<p>I had a wierd error trying to insert data using a formview today.</p>
<p>The jist is this: the formview was trying to use an empty string for an int field instead of Nothing.<br />
Here is the error I saw, helpful huh?</p>
<p><span></p>
<h2><em><span style="color: #a52a2a;">Failed to set one or more properties on type xxxxxxx  Ensure that the input values are valid and can be converted to the corresponding property types.</span></em></h2>
<p></span></p>
<p>The fields are allowed to be null but the formview just isn&#8217;t smart enough to use nothing instead of &#8220;&#8221;.</p>
<p>My workaround was simple and flexible enough to be re-used so I figured I would post it here.<br />
I simply hijack the formview&#8217;s onInserting and replaced &#8220;&#8221; with Nothing for each field.</p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="color: #0000ff; font-size: x-small;">Protected</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Sub</span><span style="font-size: x-small;"> formView1_ItemInserting(</span><span style="color: #0000ff; font-size: x-small;">ByVal</span><span style="font-size: x-small;"> sender </span><span style="color: #0000ff; font-size: x-small;">As</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Object</span><span style="font-size: x-small;">, </span><span style="color: #0000ff; font-size: x-small;">ByVal</span><span style="font-size: x-small;"> e </span><span style="color: #0000ff; font-size: x-small;">As</span><span style="font-size: x-small;"> System.Web.UI.WebControls.FormViewInsertEventArgs)</span></p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="color: #0000ff; font-size: x-small;"> For</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Each</span><span style="font-size: x-small;"> o </span><span style="color: #0000ff; font-size: x-small;">As</span><span style="font-size: x-small;"> DictionaryEntry </span><span style="color: #0000ff; font-size: x-small;">In</span><span style="font-size: x-small;"> e.Values<br />
</span><span style="color: #0000ff; font-size: x-small;">If</span><span style="font-size: x-small;"> o.Value = </span><span style="color: #a31515; font-size: x-small;">&#8220;&#8221;</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Then</span><span style="font-size: x-small;"> e.Values(o.Key) = </span><span style="color: #0000ff; font-size: x-small;">Nothing<br />
</span><span style="color: #0000ff; font-size: x-small;"> Next</span></p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="color: #0000ff; font-size: x-small;">End</span><span style="font-size: x-small;"> </span><span style="color: #0000ff; font-size: x-small;">Sub</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/02/05/insert-with-formview-using-linq/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217;</title>
		<link>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/</link>
		<comments>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:49:52 +0000</pubDate>
		<dc:creator>B.Harding</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Visual Studio 2007]]></category>

		<guid isPermaLink="false">http://www.npathweb.com/blog/?p=5</guid>
		<description><![CDATA[I had this error pop up on me recently.

Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217;
I had an good grasp on why but the stack track would not tell me where!
The issue is that a null object was being used in a where clause somewhere. Linq translated the null as &#8220;&#8221; and could not [...]]]></description>
			<content:encoded><![CDATA[<p>I had this error pop up on me recently.</p>
<p><span></p>
<h2><em>Operator &#8216;==&#8217; incompatible with operand types &#8216;Int32&#8242; and &#8216;Object&#8217;</em></h2>
<p></span>I had an good grasp on why but the stack track would not tell me where!</p>
<p>The issue is that a null object was being used in a where clause somewhere. Linq translated the null as &#8220;&#8221; and could not be compared the the ID field which is an int.</p>
<p>My solution was to simply check each key and cancel the action if there is a null value.</p>
<p>Since I couldn&#8217;t tell which Linq Data source was crashing I wired up on selecting events for them ALL and put the following code in:</p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="color: #0000ff; font-size: x-small;">foreach</span><span style="font-size: x-small;"> (</span><span style="color: #2b91af; font-size: x-small;">KeyValuePair</span><span style="font-size: x-small;">&lt;</span><span style="color: #0000ff; font-size: x-small;">string</span><span style="font-size: x-small;">, </span><span style="color: #0000ff; font-size: x-small;">object</span><span style="font-size: x-small;">&gt; kvp </span><span style="color: #0000ff; font-size: x-small;">in</span><span style="font-size: x-small;"> e.WhereParameters)<br />
</span><span style="font-size: x-small;">{</span></p>
<p><span style="color: #0000ff; font-size: x-small;"> if</span><span style="font-size: x-small;"> (kvp.Value == </span><span style="color: #0000ff; font-size: x-small;">null</span><span style="font-size: x-small;">){</span></p>
<p><span style="font-size: x-small;"> e.Cancel = </span><span style="color: #0000ff; font-size: x-small;">true</span><span style="font-size: x-small;">;</span></p>
<p><span style="color: #0000ff; font-size: x-small;"> return</span><span style="font-size: x-small;">;</span></p>
<p><span style="font-size: x-small;"> }</span></p>
<p><span style="font-size: x-small;">}</span></p>
<p><span style="font-size: x-small;"> </span></p>
<p><span style="font-size: x-small;">Problem solved.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.npathweb.com/2009/02/05/operator-incompatible-with-operand-types-int32-and-object/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
