Serializable Linq Expressions

Remote Linq allows to translate System.Linq.Expressions.Expression trees (Linq Expression) into a serializable expression trees (Remote Linq Expression). Converting Linq Expressions into Remote Linq Expressions and vice versa is as simple as calling ToLinqExpression and ToRemoteLinqExpression.

Sample:

// create linq expression
System.Linq.Expressions.Expression<Func<Order, bool>> linqExpression =
  order => order.Items.Where(i => i.ProductId == prodId).Sum(i => i.Quantity) > 1;

// transform linq expression into serializable expression tree
Remote.Linq.Expressions.LambdaExpression serializableExpression =
  linqExpression.ToRemoteLinqExpression();

// transform serializable expression tree back into linq expression
System.Linq.Expressions.Expression<Func<Order, bool>> recreatedLinqExpression =
  serializableExpression.ToLinqExpression<Order, bool>();

Last edited Sep 11, 2014 at 9:14 PM by ChristofSenn, version 3