<?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>the jackol's den &#187; linq to sql</title>
	<atom:link href="http://www.thejackol.com/tag/linq-to-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thejackol.com</link>
	<description>01100010 01101100 01100101 01101000</description>
	<lastBuildDate>Wed, 28 Dec 2011 03:40:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get LINQ to SQL results into a DataTable</title>
		<link>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/</link>
		<comments>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 08:33:09 +0000</pubDate>
		<dc:creator>Mikhail Esteves</dc:creator>
				<category><![CDATA[C#/.NET]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[linq to sql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.thejackol.com/?p=594</guid>
		<description><![CDATA[There are two ways to get LINQ to SQL results into a DataTable, as explained here. I use Sample II: public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query) { if (query == null) { throw new ArgumentNullException(&#34;query&#34;); } IDbCommand cmd = ctx.GetCommand(query as IQueryable); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = (SqlCommand)cmd; DataTable dt = new DataTable(&#34;sd&#34;); [...]]]></description>
			<content:encoded><![CDATA[	<p>There are two ways to get <span class="caps">LINQ</span> to <span class="caps">SQL</span> results into a DataTable, <a href="http://www.c-sharpcorner.com/UploadFile/VIMAL.LAKHERA/LINQResultsetToDatatable06242008042629AM/LINQResultsetToDatatable.aspx" ref="external nofollow">as explained here</a>.</p>

	<p>I use Sample II:</p>

<pre><code>public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
{
     if (query == null)
     {
          throw new ArgumentNullException(&#34;query&#34;);
     }
</code>
<code>     IDbCommand cmd = ctx.GetCommand(query as IQueryable);
     SqlDataAdapter adapter = new SqlDataAdapter();
     adapter.SelectCommand = (SqlCommand)cmd;
     DataTable dt = new DataTable(&#34;sd&#34;);
</code>
<code>     try
     {
          cmd.Connection.Open();
          adapter.FillSchema(dt, SchemaType.Source); 
          adapter.Fill(dt);
     }
     finally
     {
          cmd.Connection.Close();
     }
     return dt;
}
</code></pre>

	<p>//</p>]]></content:encoded>
			<wfw:commentRss>http://www.thejackol.com/2009/06/02/get-linq-to-sql-results-into-a-datatable/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

