<?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>LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx</link><description>With the introduction of LINQ to DataSet there finally exists a full featured query language for the DataSet. Now your ability to query your data is limited only by CLR, which is no small thing! For an introduction on LINQ to DataSet, please see this</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#4601877</link><pubDate>Tue, 28 Aug 2007 05:55:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4601877</guid><dc:creator>Jonathan Carter</dc:creator><description>&lt;p&gt;Excellent post Erick. I look forward to seeing more specifics about the LinqDataView.&lt;/p&gt;</description></item><item><title>re: LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#5001811</link><pubDate>Thu, 20 Sep 2007 01:19:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5001811</guid><dc:creator>Ashraf ElSwify</dc:creator><description>&lt;p&gt;Thanks a lot for the post. It was really great.&lt;/p&gt;
&lt;p&gt;I have started to learn and read about data binding and forms in .Net 2.0. I also jumped with excitement to learn about Linq and specially Linq-to-Dataset and the only reason I was hoping for great and seamless integration of the latter with forms and data binding.&lt;/p&gt;
&lt;p&gt;I will be waiting on more of your posts to around this topic.&lt;/p&gt;</description></item><item><title>LINQ to DataSet Data Binding – Introducing LinqDataView </title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#5300018</link><pubDate>Fri, 05 Oct 2007 23:24:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5300018</guid><dc:creator>ADO.NET, LINQ, DataSet and other fun .NET technology</dc:creator><description>&lt;p&gt;It's long overview, but I finally was able to finish a few more posts on this series. Let me know if&lt;/p&gt;
</description></item><item><title>LINQ to DataSet DataBinding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#5423620</link><pubDate>Fri, 12 Oct 2007 18:05:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5423620</guid><dc:creator>ADO.NET team blog</dc:creator><description>&lt;p&gt;Interested in hearing more? Check out this great post by Erick Thompson our DataSet PM on his blog .&lt;/p&gt;
</description></item><item><title>re: LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#5434359</link><pubDate>Sat, 13 Oct 2007 06:17:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5434359</guid><dc:creator>speed</dc:creator><description>&lt;P&gt;did you do any speed tests between the various ways to see which would be most optmal?&lt;/P&gt;</description></item><item><title>Izindaba #14</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#5517820</link><pubDate>Fri, 19 Oct 2007 07:52:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5517820</guid><dc:creator>From the software development trenches</dc:creator><description>&lt;p&gt;Time for another weekly roundup of news that focuses on .NET, agile and general development content:&lt;/p&gt;
</description></item><item><title>re: LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#7134196</link><pubDate>Wed, 16 Jan 2008 23:06:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7134196</guid><dc:creator>GMA Bill</dc:creator><description>&lt;p&gt;CopyToDataTable or ToDataTable does not exist in the released version of VB9!!!&lt;/p&gt;</description></item><item><title>re: LINQ to DataSet – Data Binding</title><link>http://blogs.msdn.com/erickt/archive/2007/08/24/linq-to-dataset-data-binding.aspx#8792338</link><pubDate>Wed, 30 Jul 2008 23:12:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8792338</guid><dc:creator>Howie</dc:creator><description>&lt;p&gt;This page also gives a useful alternative way to adapt LINQ query results to a DataTable:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx"&gt;http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;sample copied here:&lt;/p&gt;
&lt;p&gt;public static DataTable LINQToDataTable&amp;lt;T&amp;gt;(IEnumerable&amp;lt;T&amp;gt; varlist)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; DataTable dtReturn = new DataTable();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; // column names &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; PropertyInfo[] oProps = null;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; if (varlist == null) return dtReturn;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; foreach (T rec in varlist)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Use reflection to get property names, to create table, Only first time, others &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;will follow &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (oProps == null)&lt;/p&gt;
&lt;p&gt; &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; oProps = ((Type)rec.GetType()).GetProperties();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (PropertyInfo pi in oProps)&lt;/p&gt;
&lt;p&gt; &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 = pi.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() &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;==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;dtReturn.Columns.Add(new DataColumn(pi.Name, colType));&lt;/p&gt;
&lt;p&gt; &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;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataRow dr = dtReturn.NewRow();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;foreach (PropertyInfo pi in oProps)&lt;/p&gt;
&lt;p&gt; &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; dr[pi.Name] = pi.GetValue(rec, null) == null ?DBNull.Value :pi.GetValue&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (rec,null);&lt;/p&gt;
&lt;p&gt; &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;dtReturn.Rows.Add(dr);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; return dtReturn;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;---------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;Example: To use this method, just use the following code sample:&lt;/p&gt;
&lt;p&gt;---------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;var vrCountry = from country in objEmpDataContext.CountryMaster&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;select new {country.CountryID,country.CountryName};&lt;/p&gt;
&lt;p&gt;DataTable dt = LINQToDataTable(vrCountry);&lt;/p&gt;</description></item></channel></rss>