<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx</link><description>So earlier today I was lamenting that an anonymous type can't be shared between functions with Wes Dyer , when he said "Well actually they can..." 
 Cue me learning something cool. 
 The first step is to create a seemingly innocent method: 
 public</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#10285983</link><pubDate>Wed, 21 Mar 2012 16:56:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10285983</guid><dc:creator>César F. Qüeb</dc:creator><description>&lt;p&gt;Awesome!!.. I was having a bad day with anonymous types.. as result of an lambda expression via LinQ to SQL.&lt;/p&gt;
&lt;p&gt;Thank you for this useful tip.&lt;/p&gt;
&lt;p&gt;Cheers.&lt;/p&gt;
&lt;p&gt;CQ&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10285983" width="1" height="1"&gt;</description></item><item><title>re: T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#9920440</link><pubDate>Tue, 10 Nov 2009 21:29:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9920440</guid><dc:creator>AlexY</dc:creator><description>&lt;p&gt;Alex and Eli Arbel &lt;/p&gt;
&lt;p&gt;Your extension methods are big help when working on EF level and want to use &amp;nbsp;functions which may return &lt;/p&gt;
&lt;p&gt;anonymous type (or IEnumerable&amp;lt;anonymous type&amp;gt;)&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9920440" width="1" height="1"&gt;</description></item><item><title>Anonymous types sharing or why it's still sucks?</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#9263064</link><pubDate>Thu, 01 Jan 2009 22:03:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9263064</guid><dc:creator>Just Code - Tamir Khason</dc:creator><description>&lt;p&gt;[This blog was migrated. You will not be able to comment here. The new URL of this post is &lt;a rel="nofollow" target="_new" href="http://khason"&gt;http://khason&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9263064" width="1" height="1"&gt;</description></item><item><title>Share anonymous types between functions </title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#8957129</link><pubDate>Thu, 18 Sep 2008 14:06:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8957129</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8957129" width="1" height="1"&gt;</description></item><item><title>re: T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#8327406</link><pubDate>Thu, 20 Mar 2008 16:59:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8327406</guid><dc:creator>aelij</dc:creator><description>&lt;p&gt;Great tip! I also added to these two:&lt;/p&gt;
&lt;p&gt;public static IEnumerable&amp;lt;T&amp;gt; CastByExample&amp;lt;T&amp;gt;(this IEnumerable o, T example)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return (IEnumerable&amp;lt;T&amp;gt;)o;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;public static IQueryable&amp;lt;T&amp;gt; CastByExample&amp;lt;T&amp;gt;(this IQueryable o, T example)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;return (IQueryable&amp;lt;T&amp;gt;)o;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Now I can create methods that return the non-generic IEnumerable and IQueryable interfaces.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8327406" width="1" height="1"&gt;</description></item><item><title>Playing Around with Anonymous Type, Extension Method, LINQ, and Generic</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#7162621</link><pubDate>Sat, 19 Jan 2008 20:01:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7162621</guid><dc:creator>Incoherent Rambling</dc:creator><description>&lt;p&gt;I was reading this particular entry from AlexJ&amp;amp;#39;s blog, in which he discussed how to use anonymous&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7162621" width="1" height="1"&gt;</description></item><item><title>Anonymous types sharing or why it's still sucks?</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#6804800</link><pubDate>Wed, 19 Dec 2007 12:19:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6804800</guid><dc:creator>Just code - Tamir Khason</dc:creator><description>&lt;P&gt;Did you try to cast anonymous types (vars)? You are. However, you never was able to pass var from one&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6804800" width="1" height="1"&gt;</description></item><item><title>Sharing “var” across the method</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#6800783</link><pubDate>Wed, 19 Dec 2007 03:20:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6800783</guid><dc:creator>Wriju's BLOG</dc:creator><description>&lt;P&gt;One of the biggest limitation in “var” is that it cannot be shared across the methods. So if you are&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6800783" width="1" height="1"&gt;</description></item><item><title>re: T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#6531722</link><pubDate>Mon, 26 Nov 2007 17:45:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6531722</guid><dc:creator>MatthieuMEZIL</dc:creator><description>&lt;p&gt;It's a great idea to use an extension method. I did the same (without extension method) to get the elements of an anonymous typed List. What is funny in my sample is that I create the List using reflection, so without use an IEnumerable first.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blog.developpez.com/index.php?blog=121&amp;amp;title=c_3_0_creer_une_liste_de_types_anonymes&amp;amp;more=1&amp;amp;c=1&amp;amp;tb=1&amp;amp;pb=1"&gt;http://blog.developpez.com/index.php?blog=121&amp;amp;title=c_3_0_creer_une_liste_de_types_anonymes&amp;amp;more=1&amp;amp;c=1&amp;amp;tb=1&amp;amp;pb=1&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6531722" width="1" height="1"&gt;</description></item><item><title>re: T CastByExample&lt;T&gt;(object o, T example)</title><link>http://blogs.msdn.com/b/alexj/archive/2007/11/22/t-castbyexample-t-object-o-t-example.aspx#6521958</link><pubDate>Mon, 26 Nov 2007 00:35:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6521958</guid><dc:creator>bittercoder</dc:creator><description>&lt;p&gt;Thanks for the tip =) I'd always wondered if I could do something like that...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6521958" width="1" height="1"&gt;</description></item></channel></rss>