public QueryContainer(QueryBase query) : this()
		{
			query?.WrapInContainer(this);
		}
예제 #2
0
		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;
		}
예제 #3
0
		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);
		}
예제 #5
0
		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,
			};
		}
예제 #6
0
		private void Assert(
			Func<QueryContainerDescriptor<Project>, QueryContainer> fluent,
			QueryBase ois,
			Action<IQueryContainer> assert
			)
		{
			assert(fluent.InvokeQuery(new QueryContainerDescriptor<Project>()));
			assert((QueryContainer)ois);
		}
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
 public QueryContainer(QueryBase query) : this()
 {
     query?.WrapInContainer(this);
 }