<?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>Prash&#039;s Blog</title>
	<atom:link href="http://prazjain.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://prazjain.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 25 Jan 2012 16:21:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='prazjain.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Prash&#039;s Blog</title>
		<link>http://prazjain.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://prazjain.wordpress.com/osd.xml" title="Prash&#039;s Blog" />
	<atom:link rel='hub' href='http://prazjain.wordpress.com/?pushpress=hub'/>
		<item>
		<title>java.lang.VerifyError: Expecting a stackmap frame at branch target</title>
		<link>http://prazjain.wordpress.com/2012/01/19/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target/</link>
		<comments>http://prazjain.wordpress.com/2012/01/19/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 18:30:36 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[appengine]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=334</guid>
		<description><![CDATA[If you get this same error : then you need to add an attribute -XX:UseSplitVerifier to your Default VM arguments. On Eclipse : Windows -&#62; Preferences -&#62; Java -&#62; Installed JRE&#8217;s And selected and edit, the one that you are using, to include -XX:-UseSplitVerifier Hope that helps<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=334&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you get this same error :</p>
<p><pre class="brush: java;">

WARNING: Error for /doit
java.lang.VerifyError: Expecting a stackmap frame at branch target 27 in method com.yourpackage.YourServlet.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V at offset 11
 at java.lang.Class.getDeclaredConstructors0(Native Method)
 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
 at java.lang.Class.getConstructor0(Class.java:2714)
 at java.lang.Class.newInstance0(Class.java:343)
 at java.lang.Class.newInstance(Class.java:325)
 at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
 at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
 at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
 at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
 at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
 at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
 at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:78)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:362)
 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 at org.mortbay.jetty.Server.handle(Server.java:326)
 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

&amp;nbsp;

</pre></p>
<p>then you need to add an attribute <strong>-XX:UseSplitVerifier</strong> to your Default VM arguments.</p>
<p>On Eclipse : Windows -&gt; Preferences -&gt; Java -&gt; Installed JRE&#8217;s</p>
<p>And selected and edit, the one that you are using, to include <strong>-XX:-UseSplitVerifier</strong></p>
<p>Hope that helps</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/334/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/334/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/334/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=334&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2012/01/19/java-lang-verifyerror-expecting-a-stackmap-frame-at-branch-target/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match</title>
		<link>http://prazjain.wordpress.com/2012/01/06/oauth-signpost-exception-oauthnotauthorizedexception-authorization-failed-server-replied-with-a-401-this-can-happen-if-the-consumer-key-was-not-correct-or-the-signatures-did-not-match/</link>
		<comments>http://prazjain.wordpress.com/2012/01/06/oauth-signpost-exception-oauthnotauthorizedexception-authorization-failed-server-replied-with-a-401-this-can-happen-if-the-consumer-key-was-not-correct-or-the-signatures-did-not-match/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 13:00:45 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Authorization]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=325</guid>
		<description><![CDATA[I got this error when trying to post a simple tweet from my android app into twitter. I had a sample test app created in twitter that I was using for a couple of days and it worked fine with all its consumer keys / secrets. But just before I was about to release the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=325&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I got this error when trying to post a simple tweet from my android app into twitter.</p>
<p>I had a sample test app created in twitter that I was using for a couple of days and it worked fine with all its consumer keys / secrets. But just before I was about to release the android app and created a new twitter app for use in release BOOM! I get this error! All I did was replace the CONSUMER KEY  and CONSUMER SECRET.</p>
<p>I searched the net all over the place but nothing could solve my issue.</p>
<p>Here is the resolution that worked.</p>
<p>In Twitter you can create apps that are either Browser based or Client based. Earlier twitter had a mechanism where it will ask the user to choose their app type. As seen in the below screenshot.</p>
<p>Here user can easily specify whatever type of application he intends to make. Also the callback url is optional because your android app application will overwrite it anyways to receive a callback.</p>
<div class="mceTemp">
<div id="attachment_326" class="wp-caption alignnone" style="width: 753px"><a href="http://prazjain.files.wordpress.com/2012/01/twitter_previousversion_appcreationpage.png"><img class="size-full wp-image-326" title="Twitter_PreviousVersion_AppCreationPage" src="http://prazjain.files.wordpress.com/2012/01/twitter_previousversion_appcreationpage.png" alt="Previous version of Twitter's Application creation page" width="743" height="688" /></a><p class="wp-caption-text">Previous version of Twitter&#039;s Application creation page</p></div>
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"></dt>
<dd class="wp-caption-dd">Previous version of Twitter&#8217;s Application creation page</dd>
</dl>
</div>
<p>The new Twitter application creation page looks like this :</p>
<div id="attachment_328" class="wp-caption alignnone" style="width: 969px"><a href="http://prazjain.files.wordpress.com/2012/01/twitter_newversion_appcreationpage.png"><img class="size-full wp-image-328" title="Twitter_NewVersion_AppCreationPage" src="http://prazjain.files.wordpress.com/2012/01/twitter_newversion_appcreationpage.png" alt="New Version of Twitter's application creation page" width="959" height="870" /></a><p class="wp-caption-text">New Version of Twitter&#039;s application creation page</p></div>
<p>Here still the callback url is optional but what is not mentioned here in description is, this field is also used to determine if your application is a Client or Browser based application.</p>
<p>So only if you fill callback url for your application, it will be considered as browser based application else it will be considered as a client application.</p>
<p>In my case in the first test app I had set callback url but when I created a second app on twitter I left it out (because it is an optional field) and hence the Authorization failed.</p>
<p>So remember to give your application Read and Write Access and assign it a callback url so twitter will know that it is a browser based application.</p>
<p>I hope that helps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/325/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/325/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/325/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=325&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2012/01/06/oauth-signpost-exception-oauthnotauthorizedexception-authorization-failed-server-replied-with-a-401-this-can-happen-if-the-consumer-key-was-not-correct-or-the-signatures-did-not-match/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>

		<media:content url="http://prazjain.files.wordpress.com/2012/01/twitter_previousversion_appcreationpage.png" medium="image">
			<media:title type="html">Twitter_PreviousVersion_AppCreationPage</media:title>
		</media:content>

		<media:content url="http://prazjain.files.wordpress.com/2012/01/twitter_newversion_appcreationpage.png" medium="image">
			<media:title type="html">Twitter_NewVersion_AppCreationPage</media:title>
		</media:content>
	</item>
		<item>
		<title>Cannot convert lambda expression to type &#8216;string&#8217; because it is not a delegate type</title>
		<link>http://prazjain.wordpress.com/2011/11/07/cannot-convert-lambda-expression-to-type-string-because-it-is-not-a-delegate-type/</link>
		<comments>http://prazjain.wordpress.com/2011/11/07/cannot-convert-lambda-expression-to-type-string-because-it-is-not-a-delegate-type/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 12:34:00 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Querying]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=311</guid>
		<description><![CDATA[This error happens over and over but only after considerable time when you have forgotten how you fixed it last time. This is the solution specified here  (rewriting here in case it helps you) Add reference to System.Data.DataSetExtensions Add using for System.Data and System.Linq But this still did not work for me. What I missed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=311&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This error happens over and over but only after considerable time when you have forgotten how you fixed it last time.</p>
<p><pre class="brush: csharp;">
            foreach (string colName in breakup)
            {
                IEnumerable res = from row in QueryCSVModel.FilteredData.Table
                                  select row[colName];    //error on select : Cannot convert lambda expression to type 'string' because it is not a delegate type
                //do something here
            }
</pre></p>
<p>This is the solution specified <a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/ad34a9f1-2849-478d-9405-b07a54b09aaf/">here  </a>(rewriting here in case it helps you)</p>
<ul>
<li>Add reference to System.Data.DataSetExtensions</li>
<li>Add using for System.Data and System.Linq</li>
</ul>
<p>But this still did not work for me.</p>
<p>What I missed is using AsEnumerable() after DataTable, this code below works</p>
<p><pre class="brush: csharp;">
            foreach (string colName in breakup)
            {
                IEnumerable res = from row in QueryCSVModel.FilteredData.Table.AsEnumerable()
                                  select row[colName];
                //do something here
            }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/311/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/311/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/311/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=311&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2011/11/07/cannot-convert-lambda-expression-to-type-string-because-it-is-not-a-delegate-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>How to Select or Project some columns from a Datatable programmatically without SQL</title>
		<link>http://prazjain.wordpress.com/2011/11/07/how-to-select-or-project-some-columns-from-a-datatable-programmatically-without-sql/</link>
		<comments>http://prazjain.wordpress.com/2011/11/07/how-to-select-or-project-some-columns-from-a-datatable-programmatically-without-sql/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 11:26:08 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Columns]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Querying]]></category>
		<category><![CDATA[Select]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=302</guid>
		<description><![CDATA[If you want to filter a few rows you a give a conditional expression that will be applied and you get only the resulting rows that satify the conditional expression. But what if you have around 50 columns and you do not want to see all of them in the result after a select query. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=302&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to filter a few rows you a give a conditional expression that will be applied and you get only the resulting rows that satify the conditional expression.</p>
<p>But what if you have around 50 columns and you do not want to see all of them in the result after a select query.</p>
<p>So how do you remove the extra columns? This is how I worked around removing the columns I did not need.</p>
<p>Steps:</p>
<ol>
<li>Get the rows that satify the filter search criteria</li>
<li>Import them and create a new table</li>
<li>Now all I am doing is, if the the column name is not part of SelectedColumn (string property) then I just remove it from the data table&#8217;s column collection. (Of course you cannot remove it in the &#8216;for&#8217; loop because you cannot edit the collection underlying the enumerator while you are running through the enumerator. So just store it in a temporary collection and remove them later).</li>
<li>Thats it, you have your results!</li>
</ol>
<div><pre class="brush: csharp;">
        private void btnExecute_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder queryBuilder = new StringBuilder();
            //Filter the rows that satisfy the conditional expression
            DataRow[] rows = QueryCSVModel.Data.Table.Select(QueryCSVModel.FilterCriteria);
            //Clone the table to create a new one, and import the eligible rows
            DataTable dt = QueryCSVModel.Data.Table.Clone();
            foreach (DataRow item in rows)
            {
                dt.ImportRow(item);
            }
            List&lt;DataColumn&gt; toRemove = new List&lt;DataColumn&gt;();
            foreach (DataColumn col in dt.Columns)
            {
                //Any column name that is not desired (not in selected columns) is to be removed.
                if (!string.IsNullOrWhiteSpace(QueryCSVModel.SelectedColumns) &amp;&amp; !QueryCSVModel.SelectedColumns.Contains(col.ColumnName))
                {
                    toRemove.Add(col);
                }
            }
            // iterate over data column collection and remove the unwanted columns.
            foreach (DataColumn col in toRemove)
	        {
                dt.Columns.Remove(col);
	        }
            //thats it, you have your data with fewer columns
            QueryCSVModel.FilteredData = dt.DefaultView;
        }
     </pre></p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/302/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=302&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2011/11/07/how-to-select-or-project-some-columns-from-a-datatable-programmatically-without-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>OleDbException is not a valid path Make sure the path name is spelled correctly</title>
		<link>http://prazjain.wordpress.com/2011/11/03/oledbexception-is-not-a-valid-path-make-sure-the-path-name-is-spelled-correctly/</link>
		<comments>http://prazjain.wordpress.com/2011/11/03/oledbexception-is-not-a-valid-path-make-sure-the-path-name-is-spelled-correctly/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 17:39:57 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[ADO]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Errors]]></category>
		<category><![CDATA[OleDbException]]></category>
		<category><![CDATA[Querying]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=290</guid>
		<description><![CDATA[It has been ages since I did ADO programming. And naturally I hit this common error when loading up my CSV file in memory. Problem:       System.Data.OleDb.OleDbException was unhandled       Message=&#8217;C:\CSVTasks\TXT2_RMMTRADE_20101124EOD_20101125_RERUN.CSV&#8217; is not a valid path.       Make sure that the path name is spelled correctly  and that you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=290&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It has been ages since I did ADO programming. And naturally I hit this common error when loading up my CSV file in memory.</p>
<p><span style="text-decoration:underline;"><strong>Problem:</strong></span></p>
<h3>      System.Data.OleDb.OleDbException was unhandled</h3>
<h3>      Message=&#8217;C:\CSVTasks\TXT2_RMMTRADE_20101124EOD_20101125_RERUN.CSV&#8217; is not a valid path.</h3>
<h3>      Make sure that the path name is spelled correctly  and that you are connected to the server on which the file resides.</h3>
<h3>      Source=Microsoft JET Database Engine ErrorCode=-2147467259</h3>
<p><span style="text-decoration:underline;"><strong>Reason:</strong></span></p>
<p>The reason this happens is if you give the full file path in the connection string or if you give just the relative file path when creating Data Adapter using select command text.</p>
<p>example:</p>
<p><pre class="brush: csharp; collapse: false;">
            // if you have given full file path below, then it will cause this issue
            string connStr = &quot;Provider=Microsoft.Jet.OleDb.4.0;Data Source=&quot; + filePathFull + &quot;;Extended Properties=\&quot;Text;HDR=YES;FMT=Delimited\&quot;&quot;;
            OleDbConnection conn = new OleDbConnection(connStr);
            conn.Open();
</pre></p>
<p>Or if you give just the file name (relative url) when loading file in adapter you will get this exception:</p>
<p><pre class="brush: csharp; collapse: false;">
            // if you have given just the file name (not full path) below then it will cause this issue
            OleDbDataAdapter adapter = new OleDbDataAdapter(&quot;SELECT * FROM &quot; + fileName, conn);
            DataSet ds = new DataSet(&quot;QueryCSV&quot;);
            adapter.Fill(ds);
</pre></p>
<p><span style="text-decoration:underline;"><strong>Solution:</strong></span></p>
<p>To avoid this issue</p>
<ol>
<li>You need to give the full path to the directory when your CSV or Text file resides, in the connection string.</li>
<li>You need to give the full file path in the select command text when creating data adapter.</li>
</ol>
<p>Code sample</p>
<p><pre class="brush: csharp; collapse: false;">
    public class CSVReader
    {
        public static DataView GetData(string fileFullPath,string directoryFullPath)
        {
            // give full path to DIR here
            string connStr = &quot;Provider=Microsoft.Jet.OleDb.4.0;Data Source=&quot; + directoryFullPath + &quot;;Extended Properties=\&quot;Text;HDR=YES;FMT=Delimited\&quot;&quot;;
            OleDbConnection conn = new OleDbConnection(connStr);
            conn.Open();
            // give full path to the file here
            OleDbDataAdapter adapter = new OleDbDataAdapter(&quot;SELECT * FROM &quot; + fileFullPath, conn);
            DataSet ds = new DataSet(&quot;QueryCSV&quot;);
            adapter.Fill(ds);
            DataTable dt = ds.Tables[0];
            conn.Dispose();
            return dt.AsDataView();
        }
    }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/290/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=290&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2011/11/03/oledbexception-is-not-a-valid-path-make-sure-the-path-name-is-spelled-correctly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>Odbc drivers not found on Windows 7 Home 64 bit OS</title>
		<link>http://prazjain.wordpress.com/2010/12/05/odbc-drivers-not-found-on-windows-7-home-64-bit-os/</link>
		<comments>http://prazjain.wordpress.com/2010/12/05/odbc-drivers-not-found-on-windows-7-home-64-bit-os/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 02:22:51 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[ODBC]]></category>
		<category><![CDATA[Open Database Connectivity]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=269</guid>
		<description><![CDATA[I was writing an application that used ODBC drivers but then realized that none of the odbc drivers were present when I check in Control Panel &#8211;&#62; ODBC sources. I see only two options SQL Server and SQL Server native client. To see the other options that you used to see earlier, run the executable [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=269&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was writing an application that used ODBC drivers but then realized that none of the odbc drivers were present when I check in Control Panel &#8211;&gt; ODBC sources. I see only two options SQL Server and SQL Server native client.</p>
<p>To see the other options that you used to see earlier, run the executable mentioned below :</p>
<p><pre class="brush: plain;"> C:\Windows\SysWOW64\odbcad32.exe </pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/269/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/269/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/269/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=269&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2010/12/05/odbc-drivers-not-found-on-windows-7-home-64-bit-os/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>Create Custom Routing Events in WPF</title>
		<link>http://prazjain.wordpress.com/2010/05/19/create-custom-routing-events-in-wpf/</link>
		<comments>http://prazjain.wordpress.com/2010/05/19/create-custom-routing-events-in-wpf/#comments</comments>
		<pubDate>Wed, 19 May 2010 22:46:47 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Custom Events]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=250</guid>
		<description><![CDATA[WPF provides a ton of events in its library, but its not too tough if you have to create a custom event to support a specific scenario. In a small example below we will create a custom event that would sort the text we enter in the textbox. Screen before and after the command execution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=250&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>WPF provides a ton of events in its library, but its not too tough if you have to create a custom event to support a specific scenario.<br />
In a small example below we will create a custom event that would sort the text we enter in the textbox.<br />
Screen before and after the command execution :</p>
<p><a href="http://prazjain.files.wordpress.com/2010/05/sortw2.png"><img class="alignnone size-full wp-image-253" title="sortW2" src="http://prazjain.files.wordpress.com/2010/05/sortw2.png" alt="" width="300" height="125" /></a><a href="http://prazjain.files.wordpress.com/2010/05/sortw1.jpg"><img class="alignnone size-full wp-image-252" title="sortW1" src="http://prazjain.files.wordpress.com/2010/05/sortw1.jpg" alt="" width="300" height="125" /></a></p>
<ul>
<li>Create a new WPF project, name it CustomEvents.</li>
</ul>
<ul>
<li>Copy paste the XAML below in Window1.xaml file</li>
</ul>
<p><pre class="brush: csharp;">

&lt;StackPanel&gt;
 &lt;TextBox Name=&quot;textBox&quot; Margin=&quot;10,10&quot; /&gt;
 &lt;Button Name=&quot;btnSort&quot; HorizontalAlignment=&quot;Center&quot; Padding=&quot;10,3&quot; FontWeight=&quot;Bold&quot; Margin=&quot;10,3&quot;&gt;Sort&lt;/Button&gt;
 &lt;/StackPanel&gt;

</pre></p>
<ul>
<li>Create a custom command for our use:</li>
</ul>
<p><pre class="brush: csharp;">

/// &lt;summary&gt;
 /// Class that holds the custom command(s)
 /// &lt;/summary&gt;
 public class SortCommand
 {
 /// &lt;summary&gt;
 /// Actual command object
 /// &lt;/summary&gt;
 private static RoutedUICommand sortCommand;

 /// &lt;summary&gt;
 /// Property exposing the command object
 /// &lt;/summary&gt;
 public static RoutedCommand Sort
 {
 get { return sortCommand; }
 }

 /// &lt;summary&gt;
 /// Static constructor initializing the input gestures that should invoke the custom command
 /// &lt;/summary&gt;
 static SortCommand()
 {
 InputGestureCollection gestures = new InputGestureCollection();
 gestures.Add(new KeyGesture(Key.S, ModifierKeys.Control, &quot;Control-S&quot;));
 sortCommand = new RoutedUICommand(&quot;Sort Command&quot;, &quot;Sort&quot;, typeof(SortCommand), gestures);
 }
 }

</pre></p>
<ul>
<li>Now we have created a custom command and we have a UI in place. Now linkup the command object and the UI. Assuming you have not renamed Window1.xaml, paste the code below into your Window1.xaml.cs.</li>
</ul>
<p><pre class="brush: csharp;">

/// &lt;summary&gt;
 /// Interaction logic for Window1.xaml
 /// &lt;/summary&gt;
 public partial class Window1 : Window
 {
 public Window1()
 {
 InitializeComponent();
// attach the command to the button so the command can be invoked on button click
 btnSort.Command = SortCommand.Sort;
// create a command binding and attach actual handlers to the command.
 CommandBinding binding = new CommandBinding();
 binding.Command = SortCommand.Sort;
 binding.CanExecute += new CanExecuteRoutedEventHandler(binding_CanExecute);
 binding.Executed += new ExecutedRoutedEventHandler(binding_Executed);
//add the command binding to window, so it would handle the execute event
 this.CommandBindings.Add(binding);
 }

 void binding_Executed(object sender, ExecutedRoutedEventArgs e)
 {
 char[] contents = textBox.Text.ToCharArray();
 Array.Sort(contents);
 textBox.Text = new string(contents);
 }

 void binding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
// we sort only if there is some text
 e.CanExecute = textBox.Text.Length &gt; 0;
 }
 }

</pre></p>
<p>When the button is clicked as there is no command binding associated with the Sort command there, the event is routed up the element tree<br />
where the window handles the executed event.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=250&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2010/05/19/create-custom-routing-events-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>

		<media:content url="http://prazjain.files.wordpress.com/2010/05/sortw2.png" medium="image">
			<media:title type="html">sortW2</media:title>
		</media:content>

		<media:content url="http://prazjain.files.wordpress.com/2010/05/sortw1.jpg" medium="image">
			<media:title type="html">sortW1</media:title>
		</media:content>
	</item>
		<item>
		<title>Entity Framework 4.0 supports POCO</title>
		<link>http://prazjain.wordpress.com/2010/05/13/entity-framework-4-0-supports%c2%a0poco/</link>
		<comments>http://prazjain.wordpress.com/2010/05/13/entity-framework-4-0-supports%c2%a0poco/#comments</comments>
		<pubDate>Thu, 13 May 2010 20:49:55 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[POCO]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=243</guid>
		<description><![CDATA[POCO &#8211; Plain Old CLR Object In Entity Framework 3.5 an Entity Class had to extend EntityObject class which in turn implemented IEntityWithKey, IEntityWithChangeTracker, IEntityWithRelationships. All of this meant more persistence logic into a domain object, a place where it does not belong. It also made testing of these domain object a bit more complicated. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=243&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>POCO &#8211; Plain Old CLR Object</p>
<p>In Entity Framework 3.5 an Entity Class had to extend EntityObject class which in turn implemented IEntityWithKey, IEntityWithChangeTracker, IEntityWithRelationships. All of this meant more persistence logic into a domain object, a place where it does not belong. It also made testing of these domain object a bit more complicated.</p>
<p>Entity Framework 4.0 now supports POCO, so simple implementation like below could be used with EF 4.0 (database used with this example is the Microsoft AutoLot database).</p>
<p><pre class="brush: csharp;">

public class Customers {

public int CustID {   get;   set;   }

public string FirstName {   get;   set;   }

public string LastName {   get;   set;   }

}

</pre></p>
<p>This also makes the code easier to test, and it extracts the persistence logic out of domain objects.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/243/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=243&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2010/05/13/entity-framework-4-0-supports%c2%a0poco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>New C# Language Features in .Net 4.0</title>
		<link>http://prazjain.wordpress.com/2010/05/07/new-c-language-features-in%c2%a0-net%c2%a04-0/</link>
		<comments>http://prazjain.wordpress.com/2010/05/07/new-c-language-features-in%c2%a0-net%c2%a04-0/#comments</comments>
		<pubDate>Fri, 07 May 2010 23:31:12 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Contravariance]]></category>
		<category><![CDATA[Covariance]]></category>
		<category><![CDATA[Language Features]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=214</guid>
		<description><![CDATA[.Net 4.0 has added couple of new language features in C# Dynamic Lookup C# has added a new static type named &#8216;dynamic&#8217;. It supports late binding, so any calls to methods, properties, fields are not resolved at compile time. Thus an error arising due to its use is also detected at runtime. &#8216;dynamic&#8217; type provides [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=214&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>.Net 4.0 has added couple of new language features in C#</p>
<p><strong>Dynamic Lookup</strong></p>
<p>C# has added a new static type named &#8216;dynamic&#8217;. It supports late binding, so any calls to methods, properties, fields are not resolved at compile time. Thus an error arising due to its use is also detected at runtime.</p>
<p><pre class="brush: csharp;">

dynamic person = GetPerson();

// A runtime error would be generated if the object returned by GetPerson() method does not has Name property

person.Name=&quot;Prashant&quot;;

</pre></p>
<p>&#8216;dynamic&#8217; type provides a lot of help to programmers dealing with COM objects in C#</p>
<p><strong>Optional Parameters</strong></p>
<p>C# now provides the ability to assign default values to method parameters incase the caller does not intend to pass value for a parameter.</p>
<p><pre class="brush: csharp;">

void Print(string car=&quot;Mini Cooper&quot;, int price=15000)

{      Console.Writeln(string.format(&quot;Car : {0}, Price : {1}&quot;,car, price));  }

void M1()

{   Print(&quot;VW Golf&quot;);  }

</pre></p>
<p>Upon invoking M1(), it would print : &#8220;Car : VW Golf, Price : 15000&#8243;</p>
<p>This shows the parameter &#8216;price&#8217; assumed the default value.</p>
<p><strong>Named Parameter</strong></p>
<p>Method parameters can now be assigned names, so its no longer necessary that method arguments are passed in the same order as method parameters.</p>
<p><pre class="brush: csharp;">

void Print(string car=&quot;Mini Cooper&quot;, int price=15000)

{      Console.Writeln(string.format(&quot;Car : {0}, Price : {1}&quot;,car, price));  }

void M1()

{   Print(price: 16000, car: &quot;VW Golf&quot;);  }

</pre></p>
<p>Upon invoking M1(), it would print : &#8220;Car : VW Golf, Price : 16000&#8243;</p>
<p><strong>Covariance</strong></p>
<p>Covariance means that an object can be treated as less derived. This features is used to return values from methods that are more abstract.</p>
<p><pre class="brush: csharp;">

class Vehicle { ... }

class Car : Vehicle { ... }

class Test {

static void Main(string[] args)

{

...

IEnumerable&lt;Car&gt; cars = GetCars();

// this is now possible in .Net 4.0

IEnumerable&lt;Vehicle&gt; vehicles = cars;

// prior to .Net 4.0 it would have required going through 'cars' collection and add every object into a new collection vehicles

}

}
</pre></p>
<p>To allow Covariance the IEnumerable type is defined with an &#8216;out&#8217; keyword</p>
<p><pre class="brush: csharp;">

IEnumerable&lt;out T&gt; { ... }

</pre></p>
<p>&#8216;out&#8217; keyword says that its fine to take values out from the collection, adding values is not allowed.</p>
<p><strong>Contravariance</strong></p>
<p>Contravariance allows a more derived type argument to be passed into a less derived type method parameter.</p>
<p><pre class="brush: csharp;">

class Vehicle { ... }

class Car : Vehicle { ... }

class Test

{

// Contravariance is enabled by using 'in' keyword

delegate void MyHandler&lt;in T&gt; (T a);

static void Main(string[] args)

{

MyHandler&lt;Vehicle&gt; handler = (veh) =&gt; { Console.Writeln(veh); }

// below line is now allowed in .Net 4.0

MyHandler&lt;Car&gt; carHandler = handler;

}

}

</pre></p>
<p>All that it means is contravariance allows a Car (subtype) to be passed into a method that requires Vehicle (base type), which could do not harm to the execution of method. But this is only allowed when the delegate generic definition uses &#8216;in&#8217; keyword, without &#8216;in&#8217; it would fail in .Net 4.0 too!</p>
<p><strong>Events</strong></p>
<p>Events in C# look like fields / properties. Operators += and -= are overloaded to map to add and remove accessor methods.</p>
<p>Prior to C# 4.0, these generated accessors were synchronized across threads using &#8216;lock(this)&#8217; as the auto generated code decorated accessors with MethodImpl(MethodImpl.Synchronized) attribute, that meant instead of synchronizing access on that invoke &#8216;add&#8217; &amp; &#8216;remove&#8217; method, it would synchronized access across any thread that capture lock on &#8216;this&#8217; object.</p>
<p>To get across this problem, C# 4.0 changes the way the code is generated for these accessors, it generates code to test for race conditions and updates delegate list accordingly.</p>
<p>This should be a non-breaking changes unless your code is dependent on the way synchronization was implemented earlier.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/214/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=214&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2010/05/07/new-c-language-features-in%c2%a0-net%c2%a04-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use Routing Service in Virtual Earth / Bing</title>
		<link>http://prazjain.wordpress.com/2010/05/03/how-to-use-routing-service-in-virtual-earth-bing/</link>
		<comments>http://prazjain.wordpress.com/2010/05/03/how-to-use-routing-service-in-virtual-earth-bing/#comments</comments>
		<pubDate>Mon, 03 May 2010 20:19:19 +0000</pubDate>
		<dc:creator>prazjain</dc:creator>
				<category><![CDATA[Bing]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Bing Virtual Earth Routing]]></category>
		<category><![CDATA[Routing]]></category>
		<category><![CDATA[Virtual Earth]]></category>

		<guid isPermaLink="false">http://prazjain.wordpress.com/?p=184</guid>
		<description><![CDATA[In my previous article on using Geocoding service in Virtual Earth I gave an introduction on how to geo code the address. See here. In this article I will show how to use that geocoded data and calculate route information using Bing. In this article we would use the Bing Maps keys to authenticate rather [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=184&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous article on using Geocoding service in Virtual Earth I gave an introduction on how to geo code the address. <a href="http://prazjain.wordpress.com/2009/07/24/using-virtual-earth-bing-geocoding-webservice/">See here</a>.</p>
<p>In this article I will show how to use that geocoded data and calculate route information using Bing. In this article we would use the Bing Maps keys to authenticate rather than the client token that we used in last article as that if for staging environment. But if you are using the staging environment then I suggest that you use the staging url for the service wsdl and use the VEStagingToken webservice for authenticate (as shown in geocoding service article).</p>
<p>1) Add a service in your VS solution pointing to : <a href="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc?wsdl" target="_blank">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc?wsdl</a> and name it VERouterServiceReference.</p>
<p>2) Create a class RouteFetcher which would hold code to get route information for the locations passed by you.</p>
<p>3) Brief description of what the code does : It uses the Bing Maps key for authentication. It creates a WayPoint object for every location passed by you and send it to the webservice for calculating the route. In the end returning a string representation of instructions for the multi leg journey.</p>
<p>PS : Does anyone know how to paste code without losing indenting ! I have a real bad time pasting my codes here.</p>
<p><pre class="brush: csharp; collapse: true; light: false; toolbar: true;">
/// &lt;summary&gt;
 /// Plans a route through the locations passed in argument in the order specified.
 /// &lt;/summary&gt;
 /// &lt;param name=&quot;locations&quot;&gt;array of string location formatted as (latitude,longitude)&lt;/param&gt;
 /// &lt;returns&gt;&lt;/returns&gt;
 public string Route(string[] locations)
 {
 try
 {
 string results = &quot;&quot;;
 RouteRequest routeRequest = new RouteRequest();
 routeRequest.Credentials = new Credentials();
 //routeRequest.Credentials.Token = _clientToken;
 routeRequest.Credentials.ApplicationId = _key;

 Waypoint[] wayPoints = new Waypoint[locations.Length];

 int pointIndex = -1;
 foreach (string point in locations)
 {
 pointIndex++;
 wayPoints[pointIndex] = new Waypoint();
 string[] digits = point.Split(',');
 // ignore the location if the string is not correctly formatted
 if (digits.Length!=2) continue;
 wayPoints[pointIndex].Location = new Location() { Latitude = double.Parse(digits[0].Trim()), Longitude = double.Parse(digits[1].Trim()) };
 if (pointIndex == 0)
 wayPoints[pointIndex].Description = &quot;Start&quot;;
 else if (pointIndex == locations.Length)
 wayPoints[pointIndex].Description = &quot;End&quot;;
 else
 wayPoints[pointIndex].Description = string.Format(&quot;Stop #{0}&quot;, pointIndex);

 }

 routeRequest.Waypoints = wayPoints;

 RouteServiceClient routeServiceClient = new RouteServiceClient();
 RouteResponse routeResponse = routeServiceClient.CalculateRoute(routeRequest);

 StringBuilder directions = new StringBuilder(&quot;&quot;);
 if (routeResponse.Result.Legs.Length &gt; 0)
 {
 int instructionIndex = 0;
 int legIndex = 0;
 foreach (var leg in routeResponse.Result.Legs)
 {
 directions.Append(string.Format(&quot;Leg #{0}\n&quot;, ++legIndex));
 foreach (var itineraryItem in leg.Itinerary)
 {
 directions.Append(string.Format(&quot;{0}. {1}\n&quot;, ++instructionIndex, itineraryItem.Text));
 }
 Regex regex = new Regex(&quot;&lt;[a-z/:]*&gt;&quot;,RegexOptions.IgnoreCase);
 results = regex.Replace(directions.ToString(),string.Empty);
 }
 }
 else
 results = &quot;No routes found&quot;;

 return results;

 }
 catch (Exception ex)
 {
 Console.WriteLine(ex.Message);
 return &quot;Exception occurred&quot;;
 }

 }
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prazjain.wordpress.com/184/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prazjain.wordpress.com/184/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prazjain.wordpress.com/184/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prazjain.wordpress.com&amp;blog=8242592&amp;post=184&amp;subd=prazjain&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prazjain.wordpress.com/2010/05/03/how-to-use-routing-service-in-virtual-earth-bing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/566f288293e9e76f4697f886f7075496?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prazjain</media:title>
		</media:content>
	</item>
	</channel>
</rss>
