<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Using Reflection in C# to Figure Out if an Integer List Has Values</title>
	<atom:link href="http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/</link>
	<description>Specializing in Microsoft Web and Database and Sync Technologies</description>
	<lastBuildDate>Wed, 08 Sep 2010 06:48:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Peter</title>
		<link>http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/comment-page-1/#comment-24853</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 02 Jun 2009 12:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/#comment-24853</guid>
		<description>Thanks Geoff for the tip.  My problem is that I don&#039;t know ahead of time it is of type List.  Is there a way around that?</description>
		<content:encoded><![CDATA[<p>Thanks Geoff for the tip.  My problem is that I don&#8217;t know ahead of time it is of type List.  Is there a way around that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: geoffrey.mcgill</title>
		<link>http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/comment-page-1/#comment-24852</link>
		<dc:creator>geoffrey.mcgill</dc:creator>
		<pubDate>Tue, 02 Jun 2009 07:58:16 +0000</pubDate>
		<guid isPermaLink="false">http://peterkellner.net/2009/06/01/csharp-reflection-integer-list-generic/#comment-24852</guid>
		<description>Here&#039;s a general purpose Lambda Expression Extension Method that simplifies the process of getting a Property value. This should also perform better.

Extension Method
-----------------
public static Func GetProperty(this Type self, string name)
{
    ParameterExpression parameter = Expression.Parameter(typeof(X), &quot;obj&quot;);
    MemberExpression property = Expression.Property(parameter, name);
    return (Func)Expression.Lambda(typeof(Func), property, parameter).Compile();
}

Usage
--------------------
CompanyQuery query = new CompanyQuery { CompanyTypeIds = new List { 1, 2, 3, 4 } };

Type type = typeof(CompanyQuery);

Func&lt;CompanyQuery, List&gt; getList = type.GetProperty&lt;CompanyQuery, List&gt;(&quot;CompanyTypeIds&quot;);

List ids = getList(query);

bool forceNoCompile = (ids != null &amp;&amp; ids.Count &gt; 0);

Hope this helps.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a general purpose Lambda Expression Extension Method that simplifies the process of getting a Property value. This should also perform better.</p>
<p>Extension Method<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
public static Func GetProperty(this Type self, string name)<br />
{<br />
    ParameterExpression parameter = Expression.Parameter(typeof(X), &#8220;obj&#8221;);<br />
    MemberExpression property = Expression.Property(parameter, name);<br />
    return (Func)Expression.Lambda(typeof(Func), property, parameter).Compile();<br />
}</p>
<p>Usage<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
CompanyQuery query = new CompanyQuery { CompanyTypeIds = new List { 1, 2, 3, 4 } };</p>
<p>Type type = typeof(CompanyQuery);</p>
<p>Func&lt;CompanyQuery, List&gt; getList = type.GetProperty&lt;CompanyQuery, List&gt;(&#8220;CompanyTypeIds&#8221;);</p>
<p>List ids = getList(query);</p>
<p>bool forceNoCompile = (ids != null &amp;&amp; ids.Count &gt; 0);</p>
<p>Hope this helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 2/13 queries in 0.010 seconds using disk
Content Delivery Network via cdn.peterkellner.net

Served from: peterkellner.net @ 2010-09-09 11:27:41 -->