Project Description


Remote Linq is a small and easy to use library 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:

// 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>();

 

Building a LINQ interface for custom WCF services is made a breeze by using the query type provided by Remote Linq:

class Client
{
  IService serviceProxy;

  public void QueryBusinessObjects()
  {
    long prodId = 5678L;

    // compose linq query
    IQuery<Order> query = new Query<Order>(serviceProxy.GetOrders)
      .Where(order => 
order.Items.Where(i => i.ProductId == prodId).Sum(i => i.Quantity) > 1) .OrderByDescending(order => order.Items.Sum(i => i.TotalAmount)) .ThenBy(order => order.Items.Count()) .Take(10); // execute query -> retrieve data from server IEnumerable<Order> orders = query.ToList(); } }
class Server : IService
{
  IQueryable<Order> orderQueryable;

  public IEnumerable<Order> GetOrders(Query<Order> query)
  {
    List<Order> result = orderQueryable
      .ApplyQuery(query)
      .ToList();
    return result;
  }
}

 

Supports .NET Framework 3.5 Client Profile and later, Silverlight 4 and later, Windows Store apps.

 

* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Get Latest Version from NuGet
PM> Install-Package Remote.Linq
http://www.nuget.org/packages/Remote.Linq/ 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Last edited Apr 4 at 11:55 AM by ChristofSenn, version 28