public QueryContainer(QueryBase query) : this()
		{
			query?.WrapInContainer(this);
		}
Ejemplo n.º 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;
		}
Ejemplo n.º 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);
		}
Ejemplo n.º 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,
			};
		}
Ejemplo n.º 6
0
		private void Assert(
			Func<QueryContainerDescriptor<Project>, QueryContainer> fluent,
			QueryBase ois,
			Action<IQueryContainer> assert
			)
		{
			assert(fluent.InvokeQuery(new QueryContainerDescriptor<Project>()));
			assert((QueryContainer)ois);
		}
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 10
0
 public QueryContainer(QueryBase query) : this()
 {
     query?.WrapInContainer(this);
 }