<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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>Comments on: Convert List&lt;T&gt;/IEnumerable to DataTable/DataView</title>
	<atom:link href="http://www.chinhdo.com/20090402/convert-list-to-datatable/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/</link>
	<description>Chinh's not quite random thoughts on software development, .NET, gadgets, and other things.</description>
	<lastBuildDate>Wed, 01 Feb 2012 12:26:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Saif</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-99707</link>
		<dc:creator>Saif</dc:creator>
		<pubDate>Tue, 27 Sep 2011 11:58:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-99707</guid>
		<description>This is not working when I join two table with all columns selected.

var productsQuery = (from p in db.Products
                                 join c in db.Categories
                                     on p.Category_Id equals c.Category_Id
                                 where p.Vendor_Code == VendorCode
                                 select new { p,c }); 

               DataTable dt = LinqToDataTable.ToDataTable(productsQuery.ToList());

Please suggest what to do?</description>
		<content:encoded><![CDATA[<p>This is not working when I join two table with all columns selected.</p>
<p>var productsQuery = (from p in db.Products<br />
                                 join c in db.Categories<br />
                                     on p.Category_Id equals c.Category_Id<br />
                                 where p.Vendor_Code == VendorCode<br />
                                 select new { p,c }); </p>
<p>               DataTable dt = LinqToDataTable.ToDataTable(productsQuery.ToList());</p>
<p>Please suggest what to do?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chinh Do</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-90398</link>
		<dc:creator>Chinh Do</dc:creator>
		<pubDate>Thu, 07 Apr 2011 13:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-90398</guid>
		<description>Glad to hear that.</description>
		<content:encoded><![CDATA[<p>Glad to hear that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-89450</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Tue, 15 Mar 2011 22:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-89450</guid>
		<description>Dude!!! you are lifesaver. 
I&#039;ve been trying to get this #@#$ thing to work for more than 5 hours. 
Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Dude!!! you are lifesaver.<br />
I&#8217;ve been trying to get this #@#$ thing to work for more than 5 hours.<br />
Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark J</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-88890</link>
		<dc:creator>Mark J</dc:creator>
		<pubDate>Fri, 04 Mar 2011 09:24:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-88890</guid>
		<description>Very nice code - came in handy at just the right time!</description>
		<content:encoded><![CDATA[<p>Very nice code &#8211; came in handy at just the right time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chinh Do</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-86985</link>
		<dc:creator>Chinh Do</dc:creator>
		<pubDate>Tue, 08 Feb 2011 21:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-86985</guid>
		<description>Thanks for the link Allen. Will check it out. Chinh</description>
		<content:encoded><![CDATA[<p>Thanks for the link Allen. Will check it out. Chinh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-86984</link>
		<dc:creator>Allen</dc:creator>
		<pubDate>Tue, 08 Feb 2011 20:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-86984</guid>
		<description>Pretty nice! If you want to compare notes to Microsoft&#039;s version of the same thing for use as an extension method, take a look to the following MSDN link: 

http://msdn.microsoft.com/en-us/library/bb669096(v=vs.90).aspx#4</description>
		<content:encoded><![CDATA[<p>Pretty nice! If you want to compare notes to Microsoft&#8217;s version of the same thing for use as an extension method, take a look to the following MSDN link: </p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb669096(v=vs.90).aspx#4" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb669096(v=vs.90).aspx#4</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chinh Do</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-78822</link>
		<dc:creator>Chinh Do</dc:creator>
		<pubDate>Fri, 25 Jun 2010 02:39:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-78822</guid>
		<description>Hi Venkata: Appreciate your note. Glad this was helpful.</description>
		<content:encoded><![CDATA[<p>Hi Venkata: Appreciate your note. Glad this was helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkata Koppaka</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-78821</link>
		<dc:creator>Venkata Koppaka</dc:creator>
		<pubDate>Thu, 24 Jun 2010 14:22:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-78821</guid>
		<description>Very Useful dealing with custom business objects</description>
		<content:encoded><![CDATA[<p>Very Useful dealing with custom business objects</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chinh Do</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-75747</link>
		<dc:creator>Chinh Do</dc:creator>
		<pubDate>Fri, 22 Jan 2010 12:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-75747</guid>
		<description>Hi Marko:

I&#039;ve fixed the code in the article to support nullable types. As the error message suggests, DataSets do not support nullable types. So the fix I put in is to use the non-nullable counterpart when I encounter nullable types.

Chinh</description>
		<content:encoded><![CDATA[<p>Hi Marko:</p>
<p>I&#8217;ve fixed the code in the article to support nullable types. As the error message suggests, DataSets do not support nullable types. So the fix I put in is to use the non-nullable counterpart when I encounter nullable types.</p>
<p>Chinh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko</title>
		<link>http://www.chinhdo.com/20090402/convert-list-to-datatable/comment-page-1/#comment-75735</link>
		<dc:creator>Marko</dc:creator>
		<pubDate>Fri, 22 Jan 2010 12:36:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.chinhdo.com/20090402/convert-list-to-datatable/#comment-75735</guid>
		<description>I need this code badly but when I use it in my code I get the following error:

DataSet does not support System.Nullable

and it is generated on the following line:

table.Columns.Add(property.Name, property.PropertyType);

My code is identical to yours and I use your method in my BLL method such as:

        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public DataTable GetList(string sortExpression, int maximumRows, int startRowIndex)
        {
            var records = _dc.Products.OrderBy(p =&gt; p.ProductName).ToList();
            return ToDataTable(records);
        }

If you have any suggestions please help... :)</description>
		<content:encoded><![CDATA[<p>I need this code badly but when I use it in my code I get the following error:</p>
<p>DataSet does not support System.Nullable</p>
<p>and it is generated on the following line:</p>
<p>table.Columns.Add(property.Name, property.PropertyType);</p>
<p>My code is identical to yours and I use your method in my BLL method such as:</p>
<p>        [DataObjectMethod(DataObjectMethodType.Select, true)]<br />
        public DataTable GetList(string sortExpression, int maximumRows, int startRowIndex)<br />
        {<br />
            var records = _dc.Products.OrderBy(p =&gt; p.ProductName).ToList();<br />
            return ToDataTable(records);<br />
        }</p>
<p>If you have any suggestions please help&#8230; <img src='http://www.chinhdo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

