public override Expression <Func <T, bool> > ToExpression() { Expression <Func <T, bool> > leftExpression = _left.ToExpression(); Expression <Func <T, bool> > rightExpression = _right.ToExpression(); ParameterExpression paramExpr = Expression.Parameter(typeof(T)); BinaryExpression exprBody = Expression.OrElse(leftExpression.Body, rightExpression.Body); exprBody = (BinaryExpression) new ParameterReplacer(paramExpr).Visit(exprBody); Expression <Func <T, bool> > finalExpr = Expression.Lambda <Func <T, bool> >(exprBody, paramExpr); return(finalExpr); }
public static IQueryable <T> Where <T>(this IQueryable <T> queryable, Specification <T> specification) { return(queryable.Where(specification.ToExpression())); }
public static int Count <T>(this IQueryable <T> queryable, Specification <T> specification) { return(queryable.Count(specification.ToExpression())); }
public static bool All <T>(this IQueryable <T> queryable, Specification <T> specification) { return(queryable.All(specification.ToExpression())); }
public static T SingleOrDefault <T>(this IQueryable <T> queryable, Specification <T> specification) { return(queryable.SingleOrDefault(specification.ToExpression())); }
public static T Last <T>(this IQueryable <T> queryable, Specification <T> specification) { return(queryable.Last(specification.ToExpression())); }