<?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: Client-side properties and any remote LINQ provider</title>
	<atom:link href="http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider/feed" rel="self" type="application/rss+xml" />
	<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=client-side-properties-and-any-remote-linq-provider</link>
	<description>A .NET developer in silicon valley</description>
	<lastBuildDate>Sun, 25 Dec 2011 15:10:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Patrick</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-47000</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Sat, 10 Dec 2011 02:52:18 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-47000</guid>
		<description>Great work!  Any suggestions on how this might be used with interfaces?

Say you have the interface:
&lt;pre&gt;&lt;code&gt;public interface IElement {
  int UniqueId { get; }
}&lt;/code&gt;&lt;/pre&gt;
and various classes that implement the interface such as:

&lt;pre&gt;&lt;code&gt;public class User : IElement {
  private static readonly CompiledExpression _idExpression
            = DefaultTranslationOf.Property(x =&gt; x.UniqueId).Is(x =&gt; x.UserId);
  public int UniqueId { get { return _idExpression.Evaluate(this); } }
  public int UserId { get; set; }
}&lt;/code&gt;&lt;/pre&gt;

Here&#039;s what I&#039;m attempting to do at the moment, which doesn&#039;t work because the interface is being used:

&lt;pre&gt;&lt;code&gt;IQueryable source; // (could be assigned with an IQueryable on instantiation)
IList results = source.Where(x =&gt; x.UniqueId == 1).WithTranslations().ToList(); // this line causes the problem, as long as the interface is used.&lt;/code&gt;&lt;/pre&gt;

Any ideas?  I think the post above was attempting something similar.  I found another post at the following address, but couldn&#039;t quite figure out what the solution was:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/3b401086-2c58-4bd0-845b-e0209f9cdcf5

Thanks!</description>
		<content:encoded><![CDATA[<p>Great work!  Any suggestions on how this might be used with interfaces?</p>
<p>Say you have the interface:</p>
<pre><code>public interface IElement {
  int UniqueId { get; }
}</code></pre>
<p>and various classes that implement the interface such as:</p>
<pre><code>public class User : IElement {
  private static readonly CompiledExpression _idExpression
            = DefaultTranslationOf.Property(x =&gt; x.UniqueId).Is(x =&gt; x.UserId);
  public int UniqueId { get { return _idExpression.Evaluate(this); } }
  public int UserId { get; set; }
}</code></pre>
<p>Here&#8217;s what I&#8217;m attempting to do at the moment, which doesn&#8217;t work because the interface is being used:</p>
<pre><code>IQueryable source; // (could be assigned with an IQueryable on instantiation)
IList results = source.Where(x =&gt; x.UniqueId == 1).WithTranslations().ToList(); // this line causes the problem, as long as the interface is used.</code></pre>
<p>Any ideas?  I think the post above was attempting something similar.  I found another post at the following address, but couldn&#8217;t quite figure out what the solution was:<br />
<a href="http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/3b401086-2c58-4bd0-845b-e0209f9cdcf5" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/3b401086-2c58-4bd0-845b-e0209f9cdcf5</a></p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46897</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Thu, 10 Nov 2011 16:49:50 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46897</guid>
		<description>You can grab a copy of the ExpressionVisitor class from the IQToolkit at http://iqtoolkit.codeplex.com/

[)amien</description>
		<content:encoded><![CDATA[<p>You can grab a copy of the ExpressionVisitor class from the IQToolkit at <a href="http://iqtoolkit.codeplex.com/" rel="nofollow">http://iqtoolkit.codeplex.com/</a></p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Don Wilcox</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46872</link>
		<dc:creator>Don Wilcox</dc:creator>
		<pubDate>Mon, 07 Nov 2011 17:13:03 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46872</guid>
		<description>Damien,

I have attempted to use your library so solve a problem I originally asked in StackOverflow. I have a class ClientID to wrap an Int64 ID:

class ClientID {
  public Int64 Value { 
    get { return cidExpression.Evaluate(this); } 
    private set { m_Value = value; } 
  }
  public static bool operator ==(ClientID lhs, Int64 rhs) { return lhs.Value == rhs; }
  public static bool operator ==(Int64 lhs, ClientID rhs) { return rhs == lhs; }
  private Int64 m_Value;
  private static readonly CompiledExpression cidExpression = DefaultTranslationOf.Property(e =&gt; e.Value).Is(e =&gt; e.m_Value);
}

I use it as:
  var q = dc.Notes.Where(f =&gt; f.CreatorParty.ClientID == clientID).WithTranslations().ToList();

but I still receive the &quot;Could not format node &#039;Value&#039; for execute as SQL.&quot; error. I know the class is being initialized, because I am passing a ClientID as a parameter to the search method containing the LINQ code.</description>
		<content:encoded><![CDATA[<p>Damien,</p>
<p>I have attempted to use your library so solve a problem I originally asked in StackOverflow. I have a class ClientID to wrap an Int64 ID:</p>
<p>class ClientID {<br />
  public Int64 Value {<br />
    get { return cidExpression.Evaluate(this); }<br />
    private set { m_Value = value; }<br />
  }<br />
  public static bool operator ==(ClientID lhs, Int64 rhs) { return lhs.Value == rhs; }<br />
  public static bool operator ==(Int64 lhs, ClientID rhs) { return rhs == lhs; }<br />
  private Int64 m_Value;<br />
  private static readonly CompiledExpression cidExpression = DefaultTranslationOf.Property(e =&gt; e.Value).Is(e =&gt; e.m_Value);<br />
}</p>
<p>I use it as:<br />
  var q = dc.Notes.Where(f =&gt; f.CreatorParty.ClientID == clientID).WithTranslations().ToList();</p>
<p>but I still receive the &#8220;Could not format node &#8216;Value&#8217; for execute as SQL.&#8221; error. I know the class is being initialized, because I am passing a ClientID as a parameter to the search method containing the LINQ code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Radek</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46871</link>
		<dc:creator>Radek</dc:creator>
		<pubDate>Mon, 07 Nov 2011 10:44:34 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46871</guid>
		<description>Great lib, thanks!

Unfortunately, I am unable to build it for .NET 3.5, because I am missing ExpressionVisitor class.

Any suggestions for this one?

Thanks.</description>
		<content:encoded><![CDATA[<p>Great lib, thanks!</p>
<p>Unfortunately, I am unable to build it for .NET 3.5, because I am missing ExpressionVisitor class.</p>
<p>Any suggestions for this one?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred the frog</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46445</link>
		<dc:creator>Fred the frog</dc:creator>
		<pubDate>Fri, 23 Sep 2011 19:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46445</guid>
		<description>Good job.

I easily managed to make it work in a standard way.

But I hurt myself banging my head on a brick wall. I wish to have  two levels of translation and don&#039;t seem to be capable of.

My &quot;mission&quot; is to declare the client side property in an interface and having the implementation of the property made in the extension class of the interface so that many entities can expose the new client property.

One of the trick was to transform the code so that to now accept a method instead of a property as client side (interface extension cannot extend properties if I&#039;m right). That I managed ok, me thinks.

The second trick that gets me crazy is now I need to implement a second level of client side property so that in the expression of the DefaultTranslationOf, I want to use a second level of client side property so that classes that implement the interface can specify the server side fields to use in the expression. (Hope I am not talking german now).

So to illustrate

interface:&lt;pre&gt;&lt;code&gt;public interface IDataStatus { Guid StatusId { get; } }&lt;/code&gt;&lt;/pre&gt;

InterfaceExtension:&lt;pre&gt;&lt;code&gt;public static class DataStatusExtensions {
	private static readonly CompiledExpression closeStatusExpression = DefaultTranslationOf.Property(e =&gt; e.CloseStatus()).Is(e =&gt; (e.StatusId == EnumStatusIDs.Closed) &#124;&#124; (e.StatusId == EnumStatusIDs.Detached));

	public static Boolean CloseStatus(this IDataStatus dataStatus) {
		return closeStatusExpression.Evaluate(dataStatus);
	}
}&lt;/code&gt;&lt;/pre&gt;

Now in the derived class:&lt;pre&gt;&lt;code&gt;partial class Connection : IDataStatus {
	private static readonly CompiledExpression statusIdExpression = DefaultTranslationOf.Property(e =&gt; e.StatusId).Is(e =&gt; (e.EnumConnectionStatusID == null) ? Guid.Empty : e.EnumConnectionStatusID.Value);

	public Guid StatusId { get { return statusIdExpression.Evaluate(this); }
}&lt;/code&gt;&lt;/pre&gt;
... and finally some query method ...&lt;pre&gt;&lt;code&gt;query = query.Where(it =&gt; it.CloseStatus()).WithTranslations();&lt;/code&gt;&lt;/pre&gt;

My thinking is that my problem is that it does not manage to translate a IDataStatus.StatusId because the declaration in the map is a Connection.StatusId...

What do you think?

Sorry for the long post but I wished to illustrate my saying.

Thanks.</description>
		<content:encoded><![CDATA[<p>Good job.</p>
<p>I easily managed to make it work in a standard way.</p>
<p>But I hurt myself banging my head on a brick wall. I wish to have  two levels of translation and don&#8217;t seem to be capable of.</p>
<p>My &#8220;mission&#8221; is to declare the client side property in an interface and having the implementation of the property made in the extension class of the interface so that many entities can expose the new client property.</p>
<p>One of the trick was to transform the code so that to now accept a method instead of a property as client side (interface extension cannot extend properties if I&#8217;m right). That I managed ok, me thinks.</p>
<p>The second trick that gets me crazy is now I need to implement a second level of client side property so that in the expression of the DefaultTranslationOf, I want to use a second level of client side property so that classes that implement the interface can specify the server side fields to use in the expression. (Hope I am not talking german now).</p>
<p>So to illustrate</p>
<p>interface:
<pre><code>public interface IDataStatus { Guid StatusId { get; } }</code></pre>
<p>InterfaceExtension:
<pre><code>public static class DataStatusExtensions {
	private static readonly CompiledExpression closeStatusExpression = DefaultTranslationOf.Property(e =&gt; e.CloseStatus()).Is(e =&gt; (e.StatusId == EnumStatusIDs.Closed) || (e.StatusId == EnumStatusIDs.Detached));

	public static Boolean CloseStatus(this IDataStatus dataStatus) {
		return closeStatusExpression.Evaluate(dataStatus);
	}
}</code></pre>
<p>Now in the derived class:
<pre><code>partial class Connection : IDataStatus {
	private static readonly CompiledExpression statusIdExpression = DefaultTranslationOf.Property(e =&gt; e.StatusId).Is(e =&gt; (e.EnumConnectionStatusID == null) ? Guid.Empty : e.EnumConnectionStatusID.Value);

	public Guid StatusId { get { return statusIdExpression.Evaluate(this); }
}</code></pre>
<p>&#8230; and finally some query method &#8230;
<pre><code>query = query.Where(it =&gt; it.CloseStatus()).WithTranslations();</code></pre>
<p>My thinking is that my problem is that it does not manage to translate a IDataStatus.StatusId because the declaration in the map is a Connection.StatusId&#8230;</p>
<p>What do you think?</p>
<p>Sorry for the long post but I wished to illustrate my saying.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: the_bmo</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46389</link>
		<dc:creator>the_bmo</dc:creator>
		<pubDate>Wed, 07 Sep 2011 14:30:13 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46389</guid>
		<description>But where are the source?</description>
		<content:encoded><![CDATA[<p>But where are the source?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eros</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46345</link>
		<dc:creator>Eros</dc:creator>
		<pubDate>Tue, 23 Aug 2011 15:35:37 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46345</guid>
		<description>Thanks! Now it works fine!</description>
		<content:encoded><![CDATA[<p>Thanks! Now it works fine!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46344</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Tue, 23 Aug 2011 15:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46344</guid>
		<description>To create LINQ expressions with strings instead of lambda&#039;s check out the DynamicLinq samples in your VS2010 folder (it&#039;s in the C# Samples folder inside c:\Program Files\Microsoft Visual Studio).

[)amien</description>
		<content:encoded><![CDATA[<p>To create LINQ expressions with strings instead of lambda&#8217;s check out the DynamicLinq samples in your VS2010 folder (it&#8217;s in the C# Samples folder inside c:\Program Files\Microsoft Visual Studio).</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eros</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46342</link>
		<dc:creator>Eros</dc:creator>
		<pubDate>Tue, 23 Aug 2011 14:39:31 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46342</guid>
		<description>Very useful article, but I wonder: there is a way to use something like this?

&lt;pre&gt;&lt;code&gt;db.Employees.Where(e =&gt; e.FullName.Contains(&quot;da&quot;)).OrderBy(&quot;it.FullName ASC&quot;).WithTranslations();&lt;/code&gt;&lt;/pre&gt;

I need a way to build the OrderBy sql string at runtime, also on the custom properties.

Many thanks!</description>
		<content:encoded><![CDATA[<p>Very useful article, but I wonder: there is a way to use something like this?</p>
<pre><code>db.Employees.Where(e =&gt; e.FullName.Contains("da")).OrderBy("it.FullName ASC").WithTranslations();</code></pre>
<p>I need a way to build the OrderBy sql string at runtime, also on the custom properties.</p>
<p>Many thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Damien Guard</title>
		<link>http://damieng.com/blog/2009/06/24/client-side-properties-and-any-remote-linq-provider#comment-46316</link>
		<dc:creator>Damien Guard</dc:creator>
		<pubDate>Sun, 14 Aug 2011 17:09:15 +0000</pubDate>
		<guid isPermaLink="false">http://damieng.com/?p=1202#comment-46316</guid>
		<description>You should just be able to grab the source and use it - there are no runtime dependencies on .NET 4.

[)amien</description>
		<content:encoded><![CDATA[<p>You should just be able to grab the source and use it &#8211; there are no runtime dependencies on .NET 4.</p>
<p>[)amien</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic page generated in 0.165 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-08 08:40:49 -->
<!-- Compression = gzip -->
