public QueryContainer(QueryBase query) : this() { query?.WrapInContainer(this); }
private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query) { var combined = new [] {leftQuery, rightQuery}; var any = combined.Any(bf => bf == null || ((IQuery) bf).Conditionless); query = any ? combined.FirstOrDefault(bf => bf != null && !((IQuery)bf).Conditionless) : null; return any; }
private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query) { var combined = new [] {leftQuery, rightQuery}; var anyEmpty = combined.Any(q => q == null || !q.IsWritable); query = anyEmpty ? combined.FirstOrDefault(q => q != null && q.IsWritable) : null; return anyEmpty; }
public QueryContainer(QueryBase query) : this() { if (query == null) return; if (query.IsStrict && !query.IsWritable) throw new ArgumentException("Query is conditionless but strict is turned on"); query.WrapInContainer(this); }
private static QueryBase Combine(QueryBase leftQuery, QueryBase rightQuery, Func<QueryContainer, QueryContainer, QueryContainer> combine) { QueryBase q; if (IfEitherIsEmptyReturnTheOtherOrEmpty(leftQuery, rightQuery, out q)) return q; IQueryContainer container = combine(leftQuery, rightQuery); var query = container.Bool; return new BoolQuery() { Must = query.Must, MustNot = query.MustNot, Should = query.Should, Filter = query.Filter, }; }
private void Assert( Func<QueryContainerDescriptor<Project>, QueryContainer> fluent, QueryBase ois, Action<IQueryContainer> assert ) { assert(fluent.InvokeQuery(new QueryContainerDescriptor<Project>())); assert((QueryContainer)ois); }
private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query) { query = null; if (leftQuery == null && rightQuery == null) { return(true); } var leftWritable = leftQuery?.IsWritable ?? false; var rightWritable = rightQuery?.IsWritable ?? false; if (leftWritable && rightWritable) { return(false); } if (!leftWritable && !rightWritable) { return(true); } query = leftWritable ? leftQuery : rightQuery; return(true); }
private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query) { var combined = new [] { leftQuery, rightQuery }; var any = combined.Any(bf => bf == null || ((IQuery)bf).Conditionless); query = any ? combined.FirstOrDefault(bf => bf != null && !((IQuery)bf).Conditionless) : null; return(any); }
private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryBase leftQuery, QueryBase rightQuery, out QueryBase query) { var combined = new [] { leftQuery, rightQuery }; var anyEmpty = combined.Any(q => q == null || !q.IsWritable); query = anyEmpty ? combined.FirstOrDefault(q => q != null && q.IsWritable) : null; return(anyEmpty); }