public static IQueryable <T> ApplyTo <T>(this IEntityQueryOptions queryOptions, IQueryable <T> query) { IQueryable <T> queryable = query; if (queryOptions != null) { if (queryOptions.Filter != null) { Expression expression = queryOptions.Filter.RemoveQuote(); queryable = queryable.Where((Expression <Func <T, bool> >)expression); } if (queryOptions.OrderBy != null) { for (int i = 0; i < queryOptions.OrderBy.Count; i++) { queryable = (IQueryable <T>)queryOptions.OrderBy[i].ApplyTo(queryable, i != 0); } } if (queryOptions.Skip != null) { queryable = queryable.Skip(queryOptions.Skip.Value); } if (queryOptions.Take != null) { queryable = queryable.Take(queryOptions.Take.Value); } } return(queryable); }
public IEnumerable <TEntity> Find(IEntityQueryOptions queryOptions = null, CommandContext context = null) { TCommandFactory commandFactory = this.CommandFactory; IFindEntitiesCommand <TEntitySet, TEntity> findEntitiesCommand = commandFactory.CreateFindCommand(queryOptions, this as TEntitySet); return(findEntitiesCommand.Execute(context)); }
public IFindEntitiesCommand <TScope, TEntity> CreateFindCommand(IEntityQueryOptions queryOptions, TScope scope) { TFind tfind = (default(TFind) == null) ? Activator.CreateInstance <TFind>() : default(TFind); tfind.QueryOptions = queryOptions; tfind.Scope = scope; return(tfind); }
protected sealed override void Validate(Expression expression) { if (this.lastValidatedExpression != expression) { IEntityQueryOptions queryOptions = this.GetQueryOptions(expression); this.lastValidatedExpression = expression; this.lastExpressionQueryOptions = queryOptions; } }
public static IQueryable <T> ApplySkipTakeTo <T>(this IEntityQueryOptions queryOptions, IQueryable <T> query) { IQueryable <T> queryable = query; if (queryOptions != null) { if (queryOptions.Skip != null) { queryable = queryable.Skip(queryOptions.Skip.Value); } if (queryOptions.Take != null) { queryable = queryable.Take(queryOptions.Take.Value); } } return(queryable); }
public void CopyFrom(IEntityQueryOptions options) { if (this.Skip != null || this.Take != null || this.Filter != null || this.OrderBy != null) { throw new InvalidOperationException(); } this.Filter = options.Filter; IReadOnlyList <OrderByClause> readOnlyList = options.OrderBy; if (readOnlyList == null) { this.orderBy = null; } else { for (int i = 0; i < readOnlyList.Count; i++) { OrderByClause clause = readOnlyList[i]; this.AddOrderingExpression(clause, i == 0); } } this.Skip = options.Skip; this.Take = options.Take; }
public EntityQueryOptionsVisitor(EntityQueryOptionsBuilder entityQueryOptionsBuilder, Expression knownExpression = null, IEntityQueryOptions knownQueryOptions = null) { this.entityQueryOptionsBuilder = entityQueryOptionsBuilder; this.knownExpression = knownExpression; this.knownQueryOptions = knownQueryOptions; this.oneArgMethods = new Dictionary <MethodInfo, Action <Expression> > { { QueryableMethods.Take, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyTake) }, { QueryableMethods.Skip, new Action <Expression>(this.entityQueryOptionsBuilder.ApplySkip) }, { QueryableMethods.Where, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyWhere) }, { QueryableMethods.OrderBy, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyOrderBy) }, { QueryableMethods.ThenBy, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyThenBy) }, { QueryableMethods.OrderByDescending, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyOrderByDescending) }, { QueryableMethods.ThenByDescending, new Action <Expression>(this.entityQueryOptionsBuilder.ApplyThenByDescending) } }; }
public IFindEntitiesCommand <MeetingRequestMessages, MeetingRequestMessage> CreateFindCommand(IEntityQueryOptions queryOptions, MeetingRequestMessages scope) { throw new NotImplementedException(); }
public IFindEntitiesCommand <Events, Event> CreateFindCommand(IEntityQueryOptions queryOptions, Events scope) { return(this.singleInstanceEventCommandFactory.CreateFindCommand(queryOptions, scope)); }
public virtual int EstimateTotalCount(IEntityQueryOptions queryOptions, CommandContext context = null) { throw new UnsupportedEstimatedTotalCountException(); }
public IFindEntitiesCommand <TScope, TEntity> CreateFindCommand(IEntityQueryOptions queryOptions, TScope scope) { throw SimpleCrudNotSupportedCommandFactory <TScope, TEntity> .CreateGenericCrudCommandException(); }