public void Finish() { if (!Finished) { _assignmentExpression = _expressionBuilder.BuildExpression(_tokens); Finished = true; } }
public static IQueryable<TSource> Build<TDbContext,TSource>(this TDbContext dbContext, IExpressionBuilder<TSource> builder) where TDbContext : DbContext where TSource : class { var dbContextExpression = Expression.Constant(dbContext,typeof(TDbContext)); var sources = builder.GetParameterTypes() .Skip(1) .Where(t=>typeof(IQueryable).IsAssignableFrom(t)) .Select(t=>t.GetGenericArguments().First()) .Select(t=>Expression.Call(dbContextExpression,nameof(dbContext.Set),new[]{t},new Expression[0])); var expr = builder.BuildExpression(sources); return dbContext.Set<TSource>().Where(expr); }
public static IQueryable <T> Where <T>(this IQueryable <T> source, IExpressionBuilder <T> builder, params IQueryable[] sources) where T : class { return(source.Where(builder.BuildExpression(sources))); }