<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tech - Noesis</title>
	<atom:link href="http://technoesis.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://technoesis.wordpress.com</link>
	<description>The more you know, you know how little you know</description>
	<lastBuildDate>Fri, 30 Dec 2011 20:20:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='technoesis.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tech - Noesis</title>
		<link>http://technoesis.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://technoesis.wordpress.com/osd.xml" title="Tech - Noesis" />
	<atom:link rel='hub' href='http://technoesis.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Moved to new location http://www.noesispedia.com</title>
		<link>http://technoesis.wordpress.com/2008/03/21/moved-to-new-location-httpwwwnoesistechlabscom/</link>
		<comments>http://technoesis.wordpress.com/2008/03/21/moved-to-new-location-httpwwwnoesistechlabscom/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 07:33:18 +0000</pubDate>
		<dc:creator>Pradeep Mishra</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[http://www.noesistechlabs.com]]></category>

		<guid isPermaLink="false">http://technoesis.wordpress.com/2008/03/21/moved-to-new-location-httpwwwnoesistechlabscom/</guid>
		<description><![CDATA[I have moved to new location http://www.noesispedia.com. Please visit this link for latest posts. Here is a small writeup about noesispedia.. What! noesispedia is a entrepreneurial and a non profit organization, started by few working professionals, working towards growth of individual through motivating creative writing, knowledge sharing and collabaration. We provide a single online platform [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=7&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have moved to new location <a title="http://www.noesispedia.com" href="http://www.noesispedia.com">http://www.noesispedia.com</a>. Please visit this link for latest posts. Here is a small writeup about noesispedia..</p>
<div>
<h1><span class="green">What!</span></h1>
<p>noesispedia is a entrepreneurial and a non profit organization, started by few working professionals, working towards growth of individual through motivating creative writing, knowledge sharing and collabaration. We provide a single online platform serving following purposes&#8230;</p>
<ul>
<li>Group Blogging: Know what your friends are writing and be in touch with them</li>
<li>Motivate individual to donate some of their time to help grow others</li>
<li>Web log problems faced in routine work</li>
<li>Share solutions with others</li>
<li>Debate on new ideas</li>
<li>Post open source projects and tools</li>
</ul>
<h1><span class="green">Why!</span></h1>
<p>Because&#8230;</p>
<ul>
<li>Very few people and publishing blog and on top that all information is scattered. 	We want to converge the knowledge and people together</li>
<li>There is no way to find out what technology/business domain your friends are working. 	We want to provide a platform to find like minded people and solutions through them</li>
<li>You want to know what&#8217;s going on in your circle</li>
<li>You face lots of problems and spend a fair amount of time in solution but you do not 	keep a track of them. In future may face the same problem again and spend the same 	effort and time. We want you to keep track of them to avoid putting the same effort 	again</li>
<li>Provide free information to all</li>
</ul>
<h1><span class="green">But!</span></h1>
<blockquote><p>noesispedia is an organization build by its contributors. All group members belong to technical field but that doesn&#8217;t mean everything here is gonna be tech stuff. No not at all. You will surely have lots of fun stuff like cartoons, music reviews, movie reviews, puzzles etc.The primary purpose of Noesis is to grow people through people.</p></blockquote>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/technoesis.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/technoesis.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/technoesis.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/technoesis.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/technoesis.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=7&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://technoesis.wordpress.com/2008/03/21/moved-to-new-location-httpwwwnoesistechlabscom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a5c63beff1a3e79ee71a620984b133a1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pkmishra</media:title>
		</media:content>
	</item>
		<item>
		<title>How to show google mail like loading image/please wait&#8230; message while page data loads</title>
		<link>http://technoesis.wordpress.com/2008/03/04/how-to-show-google-mail-like-loading-imageplease-wait-message-while-page-data-loads/</link>
		<comments>http://technoesis.wordpress.com/2008/03/04/how-to-show-google-mail-like-loading-imageplease-wait-message-while-page-data-loads/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 04:21:33 +0000</pubDate>
		<dc:creator>Pradeep Mishra</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[loading...]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://technoesis.wordpress.com/?p=6</guid>
		<description><![CDATA[For a better user experience you would your users to see please wait message while browser render the page completely. Here is the one solution to the same problem. Let&#8217;s create a master page called Site.master and a web content form as demo.aspx. Demo.aspx is the web content form which fetches data from a database. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=6&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For a better user experience you would your users to see please wait message while browser render the page completely. Here is the one solution to the same problem.</p>
<p>Let&#8217;s create a master page called Site.master and a web content form as demo.aspx.</p>
<p><pre class="brush: xml;">






    &lt;title&gt;Loading Demo&lt;/title&gt;


    &lt;form&gt;
        
            
                
            
        

&lt;div&gt;

&lt;!-- Page Header will go here... --&gt;

&lt;/div&gt;

&lt;div&gt;


                                            &lt;!-- Page-specific content will go here... --&gt;
                                        

&lt;/div&gt;

&lt;div&gt;

&lt;!-- Page Footer will go here... --&gt;

&lt;/div&gt;</pre><br />
Demo.aspx is the web content form which fetches data from a database.<br />
<pre class="brush: xml;">


&lt;!-- Code to fetch data from a database --&gt;
</pre><br />
To show loading message add following code to the code behind of master file Site.master.cs<br />

  protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                Response.Buffer = false;
                Response.Write("<div style='top:2px;left:2px;width:83px;height:19px;text-align:right;background-color:orange;'>Please wait...</div>");
                Response.Flush();
            }
            base.OnLoad(e);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            if (!IsPostBack)
            {
                Response.Clear();
                Response.ClearContent();
            }
            base.Render(writer);
        }<br />
in the Site.master.aspx file add following javascript at the end of the file.<br />
<pre class="brush: jscript;">
 
    try{
 var divLoadingMessage =  document.getElementById(&quot;divLoadingMsg&quot;)
 if (divLoadingMessage != null &amp;&amp; typeof(divLoadingMessage) != 'undefined')
        {
            divLoadingMessage.style.display=&quot;none&quot;;
            divLoadingMessage.parentNode.removeChild(divLoadingMessage);
        }
    }catch(e){}
</pre><br />
That&#8217;s it now all your pages using Site.master will be showing Please wait.. message when the page starts loading. Of course instead of putting a message you can put a nice web2.0 loading image in between divLoadingMsg tags.<br />
<b>So how does this works?</b><br />
The onLoad event of master page will be called  before any of the content web form&#8217;s Onload event. as soon as master page loads div tag becomes visible. After the page has loaded completely the script written  at the end of the master page hides the div tag. so simple isnt&#8217;t it.Hope this helps!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/technoesis.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/technoesis.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/technoesis.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/technoesis.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/technoesis.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=6&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://technoesis.wordpress.com/2008/03/04/how-to-show-google-mail-like-loading-imageplease-wait-message-while-page-data-loads/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a5c63beff1a3e79ee71a620984b133a1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pkmishra</media:title>
		</media:content>
	</item>
		<item>
		<title>Linq to Sql: Dynamic Sorting without using Complete Dynamic Linq Libraries</title>
		<link>http://technoesis.wordpress.com/2008/03/03/linq-to-sql-dynamic-sorting-without-using-complete-dynamic-linq-libraries/</link>
		<comments>http://technoesis.wordpress.com/2008/03/03/linq-to-sql-dynamic-sorting-without-using-complete-dynamic-linq-libraries/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 07:57:10 +0000</pubDate>
		<dc:creator>Pradeep Mishra</dc:creator>
				<category><![CDATA[technical]]></category>

		<guid isPermaLink="false">http://technoesis.wordpress.com/?p=5</guid>
		<description><![CDATA[This problem may occur while implementing sorting in GridView. If a storedprocedure is being used either dynamic sql can be created or multiple of case statements can be used. However what if you are just using linq queries. Here are the options Using Dynamic Linq Some work arround so that linq query can be generated [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=5&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This  problem may occur while implementing sorting in GridView. If a storedprocedure is being used either dynamic sql can be created or multiple of case statements can be used. However what if you are just using linq queries. Here are the options</p>
<ol>
<li>Using Dynamic Linq</li>
<li>Some work arround so that linq query can be generated at runtime.</li>
</ol>
<p>Essentially 2nd approach is the same as that used in 1st one. But if you just want to implement sorting and do not want to digg into Dynamic Linq libraries you can follow the article&#8230;</p>
<p>Let&#8217;s assume following method expects sortExpression parameter directly passed by UI layer GridView.</p>
<p>
public DataTable GetSomeData(par1, par2...., string sortExpression)
{
var query = (//Linq query goes here )
// We want something like this which is not possible as of now
var query = (some query) (OrderBy SortExpression)
}<br />
Here is the extension method you would like to follow&#8230;<br />

public DataTable GetSomeData(par1, par2...., string sortExpression)
{
var query = (//Linq query goes here )
// We want something like this which is not possible as of now
var query = (some query) (OrderBy SortExpression)
}
public static Util
{
//Thanks to Ernesto for pointing out a small correction in method signature.
 public static  IQueryable<TEntity> OrderBy(this IQueryable<TEntity> source, string sortExpression) where TEntity : class
  {
            var type = typeof(TEntity);
	// Remember that for ascending order GridView just returns the column name and for descending it returns column name followed by DESC keyword
	// Therefore we need to examine the sortExpression and separate out Column Name and order (ASC/DESC)
	string[] expressionParts = sortExpression.Split(' '); // Assuming sortExpression is like [ColoumnName DESC] or [ColumnName]
	string orderByProperty = expressionParts[0];
            string sortDirection = "ASC";
            string methodName = "OrderBy";

	//if sortDirection is descending
	if (expressionParts.Length > 1 && expressionParts[1] == "DESC")
            {
                sortDirection = "Descending";
                methodName += sortDirection; // Add sort direction at the end of Method name
            }
            var property = type.GetProperty(orderByProperty);
            var parameter = Expression.Parameter(type, "p");
            var propertyAccess = Expression.MakeMemberAccess(parameter, property);
            var orderByExp = Expression.Lambda(propertyAccess, parameter);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), methodName,
                            new Type[] { type, property.PropertyType },
                            source.Expression, Expression.Quote(orderByExp));
            return source.Provider.CreateQuery(resultExp);
        }
}<br />
Usage will be as of follows&#8230;<br />

public DataTable GetSomeData(par1, par2...., string sortExpression)
{
var query = (//Linq query goes here )
// We want something like this which is not possible as of now
var query = (some query)
return query.OrderBy(SortExpression).ToDataTable(rec => new object[] { query}));
}<br />
Again OrderBy is an extension method.   Hope this helps!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/technoesis.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/technoesis.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/technoesis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/technoesis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/technoesis.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=5&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://technoesis.wordpress.com/2008/03/03/linq-to-sql-dynamic-sorting-without-using-complete-dynamic-linq-libraries/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a5c63beff1a3e79ee71a620984b133a1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pkmishra</media:title>
		</media:content>
	</item>
		<item>
		<title>Solution to Error: The data source &#8216;ods_DataSource&#8217; does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.</title>
		<link>http://technoesis.wordpress.com/2008/03/03/solution-to-error-the-data-source-ods_datasource-does-not-support-sorting-with-ienumerable-data-automatic-sorting-is-only-supported-with-dataview-datatable-and-dataset/</link>
		<comments>http://technoesis.wordpress.com/2008/03/03/solution-to-error-the-data-source-ods_datasource-does-not-support-sorting-with-ienumerable-data-automatic-sorting-is-only-supported-with-dataview-datatable-and-dataset/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 07:20:36 +0000</pubDate>
		<dc:creator>Pradeep Mishra</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[C# 3.0]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Linq to sql]]></category>

		<guid isPermaLink="false">http://technoesis.wordpress.com/?p=4</guid>
		<description><![CDATA[Suppose you have a grid view and associated datasource as ods_DataSource. The select method is defined as Now if you try to sort on some column the following error pops up.The data source &#8216;ods_DataSource&#8217; does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.This is because to implement [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=4&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a grid view and associated datasource as ods_DataSource.<br />
<pre class="brush: xml;">
  

&lt;!-- Some other code----&gt;


</pre><br />
The select method is defined as<br />


public ISingleResult SelectMethod(){
//Get DAL Instance DALInstance 
return DALInstance.GetDATA(){} 
}<br />
Now if you try to sort on some column the following error pops up.<font color="#ff0000">The data source &#8216;ods_DataSource&#8217; does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.</font>This is because to implement sorting you must have datasource of type DataView/DataTable/DataSet. Now if you are using traditional 3 tier architecture and returning one of these three datatypes everything works fine. The problem arises when you are using Linq. There are two possible solution for this..</p>
<ol>
<li>Implement custom sorting.</li>
<li>Change  IEnumerable datatype into one of these datatypes.</li>
</ol>
<p>Here we will try to follow 2nd approach. In our data access layer we will change IEnumerable into a DataTable using an static utility class. Here is the code to perform that operation</p>
<p>

public static class Util
    {
        public static DataTable ToDataTable(this IEnumerable varlist, CreateRowDelegate fn)
        {
            DataTable dtReturn = new DataTable();
            // column names
            PropertyInfo[] oProps = null;
            // Could add a check to verify that there is an element 0
            foreach (T rec in varlist)
            {
                // Use reflection to get property names, to create table, Only first time, others will follow
                if (oProps == null)
                {
                    oProps = ((Type)rec.GetType()).GetProperties();
                   foreach (PropertyInfo pi in oProps)
                    {
 		// Note that we must check a nullable type else method will throw and error
 		Type colType = pi.PropertyType; if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable)))
                        {
 		// Since all the elements have same type you can just take the first element and get type
 			colType = colType.GetGenericArguments()[0];
                        }
                        dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
                    }
                }
                DataRow dr = dtReturn.NewRow();
 //Iterate through each property in PropertyInfo
 foreach (PropertyInfo pi in oProps)
           {
            // Handle null values accordingly
 	dr[pi.Name] = pi.GetValue(rec, null) == null ? DBNull.Value : pi.GetValue(rec, null);
           }
          dtReturn.Rows.Add(dr);
       }
     return (dtReturn);
   }
 public delegate object[] CreateRowDelegate(T t);
}<br />
Changes in the Select method<br />


public ISingleResult SelectMethod(){
//Get DAL Instance DALInstance 
return DALInstance.GetSomeData(){} 
}
public DataTable GetSomeData()
{
ISingle result = //code to get result;
return (result.ToDataTable(rec => new object[] { result}));
} <br />
As you can see ToDataTable is an extenstion method and will be available to all IEnumerable types.Obviously there are some performance overhead due to use of reflection but still this approach can be used. However for real time applications performance testing must be performed.</p>
<p>Hope this helps!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/technoesis.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/technoesis.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/technoesis.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/technoesis.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/technoesis.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=4&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://technoesis.wordpress.com/2008/03/03/solution-to-error-the-data-source-ods_datasource-does-not-support-sorting-with-ienumerable-data-automatic-sorting-is-only-supported-with-dataview-datatable-and-dataset/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a5c63beff1a3e79ee71a620984b133a1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pkmishra</media:title>
		</media:content>
	</item>
		<item>
		<title>How To Check if DataReader has certain field</title>
		<link>http://technoesis.wordpress.com/2008/03/01/hello-world/</link>
		<comments>http://technoesis.wordpress.com/2008/03/01/hello-world/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 11:08:43 +0000</pubDate>
		<dc:creator>Pradeep Mishra</dc:creator>
				<category><![CDATA[Posts from old blog]]></category>
		<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DataReader]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Friday, July 20, 2007 During development I encountered this problem. So here I am posting a solution for the same. Suppose a reader is reading result set which normally returns fields ‘A’ ‘ B’ AND ‘C’ and in some cases it also returns ‘W’.So your dataread method is likeLet’s have some object for the data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=1&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3 class="entrytitle"> <a href="http://inoesis.wordpress.com/2008/03/01/how-to-check-if-datareader-has-certain-field/" rel="bookmark"><br />
</a></h3>
<p>Friday, July 20, 2007<!-- Begin .post --></p>
<p><a title="1915690011690408633" name="1915690011690408633"></a>  <span style="font-family:trebuchet ms;">During  development I encountered this problem. So here I am posting a solution for the  same.</span><br />
<span style="font-family:trebuchet ms;">Suppose a reader is reading result set which normally returns fields ‘A’ ‘ B’ AND ‘C’ and in some cases it also returns ‘W’.So your dataread method is like</span><span style="font-family:trebuchet ms;">Let’s have some object for the data to  persist.</span><br />

Public Object DemoObject
{
//string Property A
//string Property B
//string Property C
//string Property W

//Constructor
Object(string a, string b, string c)
{
A = a;
B = b;
C = c;
W = string.Empty;
}
Object(string a, string b, string c, string w)
{
A = a;
B = b;
C = c;
W = w;
}
}

private DemoObject DataRead(SqlDataReader reader)
{
//Some Code
//
returns object as Object
}

private Object DataRead(SqlDataReader reader)
{
//Some Code
//

if(reader["A"]!=null)
string a = reader.GetString("A");
if(reader["A"]!=null)
string b = reader.GetString("B");
if(reader["A"]!=null)
string c = reader.GetString("C");
//Following line of code throws IndexOutOfRangeException
if(reader["W"]!=null)
string w = reader.GetString("W");
//Some Code
//......

returns new DemoObject(a,b,c,w);
}<br />
<span style="font-family:trebuchet ms;">It has the GetOrdinal() method as well, but it throws an exception if the reader doesn&#8217;t contain the field.</span><br />
<span style="font-family:trebuchet ms;">So<br />
the solution is to use GetSchemaTable. It returns a table holding the<br />
schema of the reader. There is one row in the table for each column<br />
returned in the reader, and the</span><br />
<span style="font-family:trebuchet ms;">columns<br />
of the schema table define properties of the reader&#8217;s result set, such<br />
as the column name, size, data type and so on. We need to filter the<br />
</span> <span style="font-family:trebuchet ms;">rows in that table to just the row matching the column we want, theschema table holds 1 row per column. The easiest way</span><br />
<span style="font-family:trebuchet ms;">to do this is with the default view.</span><br />
<span style="font-family:trebuchet ms;">e.g.  if I were looking for a row called &#8220;myrow&#8221; in a reader&#8217;s results,</span><br />
<span style="font-family:trebuchet ms;">I could do this</span><br />
<span style="font-family:courier new;">DataView myView = reader.GetSchemaTable().DefaultView;</span><span style="font-family:courier new;">myView.RowFilter = &#8220;ColumnName = &#8216;myrow&#8217; &#8220;;</span></p>
<p><span style="font-family:trebuchet ms;">So final set of code is</span></p>
<p>
//Create a method which verifies if a column exists in a particular row being read by datareader

private bool ColumnExists(SqlDataReader reader, string columnName)
{
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= '" + columnName + "'";
return (reader.GetSchemaTable().DefaultView.Count > 0);
}

So now ReadData method will look like

private Object DataRead(SqlDataReader reader)
{
//Some Code
//

if(reader["A"]!=null)
string a = reader.GetString("A");
if(reader["A"]!=null)
string b = reader.GetString("B");
if(reader["A"]!=null)
string c = reader.GetString("C");
//Check only those columns where you have doubts
if(ColumnExists(reader, "W"))
{
if( reader["W"]!=null)
string w = reader.GetString("W");
}
//Some Code
//......

returns new DemoObject(a,b,c,w);
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/technoesis.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/technoesis.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/technoesis.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/technoesis.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/technoesis.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=technoesis.wordpress.com&amp;blog=3027474&amp;post=1&amp;subd=technoesis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://technoesis.wordpress.com/2008/03/01/hello-world/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a5c63beff1a3e79ee71a620984b133a1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pkmishra</media:title>
		</media:content>
	</item>
	</channel>
</rss>
