private IQuery buildFetchManyQuery(Context context, IStore store) { IQueryBuilder builder = store.NewQueryBuilder(); if (type != null) { AttributeInfo info = new AttributeInfo("category", TypeFamily.TEXT, true, null); builder.Verify(info, MatchOp.CONTAINS, type.GetTypeName()); } if (predicate != null) { if (!(predicate is IPredicateExpression)) { throw new SyntaxError("Filtering expression must be a predicate !"); } ((IPredicateExpression)predicate).interpretQuery(context, builder); } if (type != null && predicate != null) { builder.And(); } builder.SetFirst(InterpretLimit(context, first)); builder.SetLast(InterpretLimit(context, last)); if (include != null) { builder.Project(include); } if (orderBy != null) { orderBy.interpretQuery(context, builder); } return(builder.Build()); }
public static void SetSearch(IQueryBuilder <Ordering.PurchaseOrderSearch> builder, OrderSearchArgs args) { if (args.Search == null) { return; } if (string.IsNullOrEmpty(args.Search.Value)) { return; } if (args.Columns == null) { return; } var disj = builder.Disjunction(); foreach (var col in args.Columns) { if (col.Searchable) { var item = ColumnExpressions[col.Name]; if (item != null) { disj.Add(builder.Restriction(item.Search).StartsWith(args.Search.Value)); } } } builder.And(disj); }
public void interpretQuery(Context context, IQueryBuilder builder) { if (!(left is IPredicateExpression)) { throw new SyntaxError("Not a predicate: " + left); } ((IPredicateExpression)left).interpretQuery(context, builder); if (!(right is IPredicateExpression)) { throw new SyntaxError("Not a predicate: " + right); } ((IPredicateExpression)right).interpretQuery(context, builder); builder.And(); }
protected void ApplyFuncWhere(IQueryBuilder builder, QueryWhereType whereType, QueryBuilder.QueryFunction func) { if (whereType == QueryWhereType.And) { builder.And(func); } else if (whereType == QueryWhereType.Or) { builder.Or(func); } else if (whereType == QueryWhereType.AndNot) { builder.AndNot(func); } else if (whereType == QueryWhereType.OrNot) { builder.OrNot(func); } else { throw new InvalidOperationException("Unknown query where type"); } }
protected void ApplyColumnWhere(IQueryBuilder builder, QueryWhereType whereType, string column, Func <IComparisonQueryBuilder, IQueryBuilder> func) { if (whereType == QueryWhereType.And) { func(builder.And(column)); } else if (whereType == QueryWhereType.Or) { func(builder.Or(column)); } else if (whereType == QueryWhereType.AndNot) { builder.AndNot(builder => func(builder.Where(column))); } else if (whereType == QueryWhereType.OrNot) { builder.OrNot(builder => func(builder.Where(column))); } else { throw new InvalidOperationException("Unknown query where type"); } }