Option remote Linq

Jul 23, 2011 at 9:03 PM

Hi !

Anyone aware of this project: http://interlinq.codeplex.com/ ??

Integrating this into the AppSpace would be a extrem powerful extension.

What do you think??


Jul 25, 2011 at 8:28 AM


This looks like an interesting project, I would be interested in how you think this could be integrated into the appspace. Since the appspace is based on asynchronously sending messages, it would probably look different, e.g. packing the query into a message and sending it to the server. If you are looking for a way to just transfer queries (meaning expressions that are evaluated server-side), the appspace may already contain what you are looking for. You may have seen that the publish/subscribe feature supports "filtered subscriptions", meaning you can send a predicate expression to the server, so that you only get events from the server if this expression evaluates to true (see the Publish/Subcribe page in the feature samples list). For serializing expressions we use an altered version of MetaLinq (http://metalinq.codeplex.com), which is part of the appspace package. So if you want to transfer expressions with the appspace you could use this as well, all you have to do is store your expression as "EditableExpression", e.g. like this:

public class MyPredicateMessage<T>
  private EditableExpression expr;
  public MyPredicateMessage(Expression<Predicate<T>> myexpr)
    expr = EditableExpression.CreateEditableExpression(myexpr);

  public Predicate<T> CompileExpression() //call this to get the expression at the server side
    return ((Expression<Predicate<T>>)expr.ToExpression()).Compile();

With this you can transfer expressions between appspace instances. Be aware that though that, like in entity framework queries, some things are not allowed in transferrable expressions - you may only call framework methods within such expressions, but not your own ones, which limits the possibility to perform malicious code, or accidentally call methods from libraries that are not available on the server side. You can also take a look at the implementation of the Subscribe<T> class so see how this is used in the appspace.

Best regards

Jul 25, 2011 at 6:44 PM

Hi Thomass,

thanks first, great explanation !

Sorry, I had not understand exactly, how predicates come to expressions and I'll
have to study it more. What you explain seems to fit my scenario. I am just in a "state",
where I am not really sure, if I understand the IQueryable interface too :-(
For this special feature, I thought I have to use the Zyan framework.

I'll create the "usual" linq queries and post them to my cache, which is a space,
which should evaluate the expression and send back the result [usually, just a
list]. I'll see, if I understand to use the EditableExpression instead. So, the space
could really become a remote, queryable cache. Wonderful option!