Пример #1
0
 public void Finish()
 {
     if (!Finished)
     {
         _assignmentExpression = _expressionBuilder.BuildExpression(_tokens);
         Finished = true;
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
 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)));
 }