This project has moved and is read-only. For the latest updates, please go here.

Usage

  • Refrence LinqExpressionProjection.dll and add using:
using LinqExpressionProjection.Test.Model;
  • Define your projection expression of type Expression<Func<TIn, TOut>>:
private Expression<Func<Project, double>> averageAreaSelector = p => p.Subprojects.Average(p => p.Area);
  • In query, call AsExpressionProjectable() on collection and Project<TOut>() on the expression:
var projects = (from p in ctx.Projects.AsExpressionProjectable()
select new
{
Project = p,
AverageArea = averageAreaSelector.Project<double>()
}).ToArray();

Make sure the selection expression <TIn> is of the same type as the projection (Select() call) lambda parameter

Last edited Jun 11, 2012 at 7:44 PM by AsherBarak, version 4

Comments

No comments yet.