<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx</link><description>In the original Linq CTP and the first Orcas Beta, we included a DataSet specific Linq operator called CopyToDataTable&amp;lt;T&amp;gt; (It was called ToDataTable at one point also).&amp;#160; For Beta 2 of Orcas, we ended up restricting this method to only work</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4824970</link><pubDate>Sat, 08 Sep 2007 10:22:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4824970</guid><dc:creator>Moristar</dc:creator><description>&lt;p&gt;Great thanks!!! This is good way!&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4831947</link><pubDate>Sat, 08 Sep 2007 20:33:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4831947</guid><dc:creator>rogerj</dc:creator><description>&lt;p&gt;Pingback from &lt;a rel="nofollow" target="_new" href="http://oakleafblog.blogspot.com/2007/09/linq-and-entity-framework-updates-for.html"&gt;http://oakleafblog.blogspot.com/2007/09/linq-and-entity-framework-updates-for.html&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4832757</link><pubDate>Sat, 08 Sep 2007 22:19:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4832757</guid><dc:creator>rogerj</dc:creator><description>&lt;p&gt;Sorry, entry moved to &lt;a rel="nofollow" target="_new" href="http://oakleafblog.blogspot.com/2007/09/linq-and-entity-framework-posts-for.html"&gt;http://oakleafblog.blogspot.com/2007/09/linq-and-entity-framework-posts-for.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;--rj&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4839245</link><pubDate>Sun, 09 Sep 2007 08:02:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4839245</guid><dc:creator>akula</dc:creator><description>&lt;p&gt;This is great and was exactly what I needed. &amp;nbsp;I do get an parameter mismatch error in&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;foreach (PropertyInfo p in pi)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;values[_ordinalMap[p.Name]] = p.GetValue(instance,null);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; if I use:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var a = (from m_var in dc.Ptabs&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select m_var.CAR ).Distinct();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataSet ds = new DataSet();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ds.Tables.Add(a.CopyToDataTable());&lt;/p&gt;
&lt;p&gt;but not if I do this&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var a = (from m_var in dc.Ptabs&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select new { Car = m_var.CAR }).Distinct();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataSet ds = new DataSet();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ds.Tables.Add(a.CopyToDataTable());&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4858630</link><pubDate>Tue, 11 Sep 2007 04:50:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4858630</guid><dc:creator>aconrad</dc:creator><description>&lt;p&gt;thanks - there are a couple of problems here:&lt;/p&gt;
&lt;p&gt;1) &amp;nbsp;The code is not catching the error case when the type T of the source sequence does not match the schema of the provided datatable. &amp;nbsp;I suppose I could extend the table automatically in this case.&lt;/p&gt;
&lt;p&gt;2) &amp;nbsp;The results of your query is just a sequence of scaler values. &amp;nbsp;The code wasn't really designed for this and I am not sure I see much value, but I suppose I could just make a table with a single column.&lt;/p&gt;
&lt;p&gt;I will update the sample code to fix these issues.&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4875828</link><pubDate>Wed, 12 Sep 2007 09:25:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4875828</guid><dc:creator>akula</dc:creator><description>&lt;p&gt;Thanks&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#4996809</link><pubDate>Wed, 19 Sep 2007 15:46:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4996809</guid><dc:creator>jonm</dc:creator><description>&lt;p&gt; This seems very helpful, is there a straightforward way to implement in vb.net?&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#6534156</link><pubDate>Mon, 26 Nov 2007 23:10:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6534156</guid><dc:creator>Neeta</dc:creator><description>&lt;p&gt;Hi, this post was helpful.&lt;/p&gt;
&lt;p&gt;However it seems to have problem when used with nullable types.&lt;/p&gt;
&lt;p&gt;I am using LINQ to SQL data context calss to store data base tables.Then I query these tables and get result of type &amp;quot;var&amp;quot; and then convert it to datatable using this code.&lt;/p&gt;
&lt;p&gt;Some of the tables are of nullable type.So while conversion I receive an error saying &amp;quot;DataSet does not support System.Nullable&amp;lt;&amp;gt;&amp;quot; &lt;/p&gt;
&lt;p&gt; inside the ExtendTable method, when the code tries to add columns to the &amp;quot;table&amp;quot;&lt;/p&gt;
&lt;p&gt;Pls let me know if you have any suggestions/workaround to this problem.&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Neeta&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#6731828</link><pubDate>Tue, 11 Dec 2007 09:32:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6731828</guid><dc:creator>aconrad</dc:creator><description>&lt;p&gt;ah - I will try to get the code working with nullable types over the holidays.&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#6805465</link><pubDate>Wed, 19 Dec 2007 14:08:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6805465</guid><dc:creator>Nick Lucas</dc:creator><description>&lt;p&gt;Change the code to be this in order to handle nullable types:&lt;/p&gt;
&lt;p&gt; foreach (PropertyInfo p in type.GetProperties())&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (!_ordinalMap.ContainsKey(p.Name))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Type colType = p.PropertyType;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ((colType.IsGenericType) &amp;amp;&amp;amp; (colType.GetGenericTypeDefinition() == typeof(Nullable&amp;lt;&amp;gt;)))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;colType = colType.GetGenericArguments()[0];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataColumn dc = table.Columns.Contains(p.Name) ? table.Columns[p.Name]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: table.Columns.Add(p.Name, colType);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_ordinalMap.Add(p.Name, dc.Ordinal);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#6880109</link><pubDate>Fri, 28 Dec 2007 00:43:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6880109</guid><dc:creator>adefwebserver</dc:creator><description>&lt;p&gt;Wow thank you so much! This allows me to use a LINQ query in my DAL and then bind an Object Data Source control to it. Then I can bind the GridView to the Object Data Source control and turn on sorting and paging and it all works! &lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7038564</link><pubDate>Wed, 09 Jan 2008 12:13:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7038564</guid><dc:creator>Yigit Ozmen</dc:creator><description>&lt;p&gt;Thank you all.Is there a VB version of the complete code anywhere else?Any help appreciated much.&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7045501</link><pubDate>Thu, 10 Jan 2008 00:01:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7045501</guid><dc:creator>eyunni</dc:creator><description>&lt;p&gt;I am trying to use the above idea to convert entities into datatables. However, the linq query does not expose the CopyToDataTable() method. Am I missing something here?&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7077783</link><pubDate>Fri, 11 Jan 2008 21:42:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7077783</guid><dc:creator>Andrew Conrad</dc:creator><description>&lt;p&gt;Make sure you use the namespace the you defined the DataSetLinqOperators in.&lt;/p&gt;</description></item><item><title>Pathetic Plea for help</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7078116</link><pubDate>Fri, 11 Jan 2008 22:12:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7078116</guid><dc:creator>Man vs Code</dc:creator><description>&lt;p&gt;A number of people have asked me for a VB version of the CopyToDataTable&amp;amp;lt;T&amp;amp;gt; sample I wrote a few&lt;/p&gt;
</description></item><item><title>Pathetic Plea for help</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7078593</link><pubDate>Fri, 11 Jan 2008 22:54:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7078593</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;A number of people have asked me for a VB version of the CopyToDataTable&amp;amp;lt;T&amp;amp;gt; sample I wrote a few&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7129120</link><pubDate>Wed, 16 Jan 2008 13:35:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7129120</guid><dc:creator>Ming</dc:creator><description>&lt;p&gt;I cannot find any CopyToDataTable() method......&lt;/p&gt;
&lt;p&gt;btw, i think if we just want a datatable , using the code above is &lt;/p&gt;
&lt;p&gt;sooooooooooooo complex.&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7199739</link><pubDate>Tue, 22 Jan 2008 20:09:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7199739</guid><dc:creator>Viper</dc:creator><description>&lt;p&gt;Awesome.&lt;/p&gt;
&lt;p&gt;I added in the change for Nullable types by Nick and the whole thing is working beautifully. Only thing of note is that I had to change the method names due to a conflict. I am going to check that out.&lt;/p&gt;
&lt;p&gt;Cheers.&lt;/p&gt;</description></item><item><title>LINQ CopytoDataTable in C# and in VB</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7201403</link><pubDate>Tue, 22 Jan 2008 23:14:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7201403</guid><dc:creator>Hot Topics</dc:creator><description>&lt;p&gt;There was a CopytoDataTable method in early betas of LINQ but then it disappeared. C#: Andy Conrad on&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#7498263</link><pubDate>Thu, 07 Feb 2008 00:01:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7498263</guid><dc:creator>boomhauer</dc:creator><description>&lt;p&gt;any code out there that can help load a dlinq object FROM a datatable? Im workin with webservices and still passing datasets, so would like to load up a bunch of dlinq entities from the datatables and commit them to the db... probably easier to just use the datatables, i guess...&lt;/p&gt;</description></item><item><title>实现CopyToDataTable</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#8399142</link><pubDate>Wed, 16 Apr 2008 18:55:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8399142</guid><dc:creator>works guo</dc:creator><description>&lt;p&gt;LINQ to DataSet中实现CopyToDataTable&lt;/p&gt;
</description></item><item><title>LinQ to StimulReport ? lol (Part 1)</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#8404628</link><pubDate>Thu, 17 Apr 2008 23:53:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404628</guid><dc:creator>Desenvolvimento</dc:creator><description>&lt;p&gt;A utiliza&amp;#231;&amp;#227;o do LinQ em projetos dentro do TJMT for&amp;#231;ou uma estrutura de projeto, mas ainda n&amp;#227;o estamos&lt;/p&gt;
</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#8418566</link><pubDate>Wed, 23 Apr 2008 11:19:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8418566</guid><dc:creator>Alex Sarafian</dc:creator><description>&lt;p&gt;I was looking the same thing.&lt;/p&gt;
&lt;p&gt;I tried the above solution but for various reasons I was not satisfied.&lt;/p&gt;
&lt;p&gt;One of the biggest reasons was that I like using Typed Datasets.&lt;/p&gt;
&lt;p&gt;So I tried to create my own convertion method.It stated as a proof o concept and later became something that could be done.&lt;/p&gt;
&lt;p&gt;Here is the solution I propose&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://sarafianalex.wordpress.com/2008/04/21/typed-dataset-linq-entities/"&gt;http://sarafianalex.wordpress.com/2008/04/21/typed-dataset-linq-entities/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#8770536</link><pubDate>Fri, 25 Jul 2008 02:54:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8770536</guid><dc:creator>Ed Staffin</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There seems to be a problem with the ExtendTable routine and I'm not sure how to solve it. In the routine ExtendTable there is the following code:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;For Each p As PropertyInfo In type.GetProperties()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Not _ordinalMap.ContainsKey(p.Name) Then&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim colType As Type = p.PropertyType&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If (colType.IsGenericType) AndAlso (colType.GetGenericTypeDefinition() Is GetType(Nullable(Of ))) Then&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;colType = colType.GetGenericArguments()(0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim dc As DataColumn = IIf(table.Columns.Contains(p.Name), table.Columns(p.Name), table.Columns.Add(p.Name, colType))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;_ordinalMap.Add(p.Name, dc.Ordinal)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;End If&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Next&lt;/p&gt;
&lt;p&gt;The issue seems to be that type.GetProperties() returns the columns in alphabetical order instead of the order returned from the query. Can anyone offer some ideas on how to get them back in the right order. Or, at least to be able to contruct the datatable with the columns in the right order.&lt;/p&gt;
&lt;p&gt;Thanks ... Ed&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#9050405</link><pubDate>Thu, 06 Nov 2008 23:07:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9050405</guid><dc:creator>Scott Kleinert</dc:creator><description>&lt;p&gt;I'm having the same issue as Ed. &amp;nbsp;Has anyone figured how to return columns in the same order as the query?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Scott&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#9130477</link><pubDate>Thu, 20 Nov 2008 23:55:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9130477</guid><dc:creator>Scott Kleinert</dc:creator><description>&lt;p&gt;A note on the column order...I've noticed that on my vista laptop, the order of the columns is returned as expected. &amp;nbsp;On my XP desktop, the columns are returned alphabetically. &amp;nbsp;Still don't know why...though it might help someone smarter than I.&lt;/p&gt;
&lt;p&gt;Scott&lt;/p&gt;</description></item><item><title>re: Science Project</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#9130478</link><pubDate>Thu, 20 Nov 2008 23:55:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9130478</guid><dc:creator>Scott Kleinert</dc:creator><description>&lt;p&gt;A note on the column order...I've noticed that on my vista laptop, the order of the columns is returned as expected. &amp;nbsp;On my XP desktop, the columns are returned alphabetically. &amp;nbsp;Still don't know why...though it might help someone smarter than I.&lt;/p&gt;
&lt;p&gt;Scott&lt;/p&gt;</description></item><item><title>Doesn't compile on VS 2008</title><link>http://blogs.msdn.com/aconrad/archive/2007/09/07/science-project.aspx#9868833</link><pubDate>Fri, 14 Aug 2009 00:25:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9868833</guid><dc:creator>Nikolay Sonin</dc:creator><description>&lt;p&gt;For me it throws exactly the same compilation error&lt;/p&gt;
&lt;p&gt;error CS0311: The type 'AnonymousType#1' cannot be used as type parameter 'T' in the generic type or method 'System.Data.DataTableExtensions.CopyToDataTable&amp;lt;T&amp;gt;(System.Collections.Generic.IEnumerable&amp;lt;T&amp;gt;, System.Data.DataTable, System.Data.LoadOption)'. There is no implicit reference conversion from 'AnonymousType#1' to 'System.Data.DataRow'.&lt;/p&gt;
&lt;p&gt;My code is :&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataTable tableSimCnfCopy = tableSimCnf.Clone ();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var varLst2 = &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from car in tableSimCnf.AsEnumerable()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;select new&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ModelID = car.ModelID,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VehiclePrice = car.VehiclePrice,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;APR24PercDown = car.APR24PercDown,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;APR36PercDown = car.APR36PercDown,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;APR48PercDown = car.APR48PercDown,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;APR60PercDown = car.APR60PercDown,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;APR72PercDown = car.APR72PercDown&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;};&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;varLst2.CopyToDataTable(tableSimCnfCopy, LoadOption.PreserveChanges); &lt;/p&gt;
&lt;p&gt;The last line is the line I'm getting this compile error&lt;/p&gt;</description></item></channel></rss>