public static string ToOrderClause(this QueryModel query, IQueryableDocument mapping) { var orders = query.AllBodyClauses().OfType <OrderByClause>().SelectMany(x => x.Orderings).ToArray(); if (!orders.Any()) { return(string.Empty); } return(" order by " + orders.Select(c => ToOrderClause(c, mapping)).Join(", ")); }
public static IWhereFragment BuildWhereFragment(this IDocumentSchema schema, IQueryableDocument mapping, QueryModel query) { var wheres = query.AllBodyClauses().OfType <WhereClause>().ToArray(); if (wheres.Length == 0) { return(mapping.DefaultWhereFragment()); } var where = wheres.Length == 1 ? schema.Parser.ParseWhereFragment(mapping, wheres.Single().Predicate) : new CompoundWhereFragment(schema.Parser, mapping, "and", wheres); return(mapping.FilterDocuments(query, @where)); }
internal static IWhereFragment BuildWhereFragment(this IDocumentStorage storage, QueryModel query, MartenExpressionParser parser) { var wheres = query.AllBodyClauses().OfType <WhereClause>().ToArray(); if (wheres.Length == 0) { return(storage.DefaultWhereFragment()); } var @where = wheres.Length == 1 ? parser.ParseWhereFragment(storage.Fields, wheres.Single().Predicate) : new CompoundWhereFragment(parser, storage.Fields, "and", wheres); return(storage.FilterDocuments(query, @where)); }
internal static IWhereFragment BuildWhereFragment(DocumentStore store, QueryModel query, ITenant tenant) { var mapping = tenant.MappingFor(query.SourceType()).ToQueryableDocument(); var wheres = query.AllBodyClauses().OfType <WhereClause>().ToArray(); if (wheres.Length == 0) { return(mapping.DefaultWhereFragment()); } var @where = wheres.Length == 1 ? store.Parser.ParseWhereFragment(mapping, wheres.Single().Predicate) : new CompoundWhereFragment(store.Parser, mapping, "and", wheres); return(mapping.FilterDocuments(query, @where)); }