示例#1
0
        public static T ParentQuery <T>(this T query, RepositoryQueryDescriptor parentQuery) where T : IRepositoryQuery
        {
            if (parentQuery == null)
            {
                throw new ArgumentNullException(nameof(parentQuery));
            }

            return(query.AddCollectionOptionValue(ParentQueriesKey, parentQuery.Configure()));
        }
        public static IRepositoryQuery Configure(this RepositoryQueryDescriptor configure)
        {
            IRepositoryQuery o = new RepositoryQuery();

            if (configure != null)
            {
                o = configure(o);
            }

            return(o);
        }
示例#3
0
        public Task <long> IncrementValueAsync(RepositoryQueryDescriptor <LogEvent> query, int value = 1)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            string script = $"ctx._source.value += {value};";

            return(PatchAllAsync(query, new ScriptPatch(script), o => o.ImmediateConsistency(true)));
        }
        public static IRepositoryQuery <T> Configure <T>(this RepositoryQueryDescriptor <T> configure) where T : class
        {
            IRepositoryQuery <T> o = new RepositoryQuery <T>();

            if (configure != null)
            {
                o = configure(o);
            }

            return(o);
        }
        public Task <long> IncrementYearsEmployeedAsync(RepositoryQueryDescriptor <Employee> query, int years = 1)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            string script = $"ctx._source.yearsEmployed += {years};";

            return(PatchAllAsync(query, new ScriptPatch(script), o => o.ImmediateConsistency(true)));
        }
        public static T ChildQuery <T>(this T query, TypeName childType, RepositoryQueryDescriptor childQuery) where T : IRepositoryQuery
        {
            if (childType == null)
            {
                throw new ArgumentNullException(nameof(childType));
            }
            if (childQuery == null)
            {
                throw new ArgumentNullException(nameof(childQuery));
            }

            return(query.BuildOption(ChildQueryKey, new ChildQuery {
                Type = childType, Query = childQuery.Configure()
            }));
        }
示例#7
0
        public static TQuery ChildQuery <TQuery>(this TQuery query, RepositoryQueryDescriptor childQuery) where TQuery : IRepositoryQuery
        {
            if (childQuery == null)
            {
                throw new ArgumentNullException(nameof(childQuery));
            }

            var q = childQuery.Configure();

            if (q.GetDocumentType() == typeof(object))
            {
                throw new ArgumentException("DocumentType must be set on child queries", nameof(childQuery));
            }

            return(query.AddCollectionOptionValue(ChildQueriesKey, childQuery.Configure()));
        }
示例#8
0
 public Task <FindResults <Stack> > GetIdsByQueryAsync(RepositoryQueryDescriptor <Stack> query, CommandOptionsDescriptor <Stack> options = null)
 {
     return(FindAsync(q => query.Configure().OnlyIds(), options));
 }
示例#9
0
 public Task <FindResults <Child> > QueryAsync(RepositoryQueryDescriptor <Child> query, CommandOptionsDescriptor <Child> options = null)
 {
     return(FindAsync(query, options));
 }
 public Task <FindResults <Parent> > QueryAsync(RepositoryQueryDescriptor <Parent> query)
 {
     return(FindAsync(query));
 }
 public Task <FindResults <TResult> > FindAsAsync <TResult>(RepositoryQueryDescriptor <T> query, CommandOptionsDescriptor <T> options = null) where TResult : class, new()
 {
     return(FindAsAsync <TResult>(query.Configure(), options.Configure()));
 }
 public Task <CountResult> CountAsync(RepositoryQueryDescriptor <T> query, CommandOptionsDescriptor <T> options = null)
 {
     return(CountAsync(query.Configure(), options.Configure()));
 }
 public Task <FindResults <T> > FindAsync(RepositoryQueryDescriptor <T> query, CommandOptionsDescriptor <T> options = null)
 {
     return(FindAsAsync <T>(query.Configure(), options.Configure()));
 }
示例#14
0
        public static IRepositoryQuery <TChild> ParentQuery <TChild, TParent>(this IRepositoryQuery <TChild> query, RepositoryQueryDescriptor <TParent> parentQuery) where TChild : class where TParent : class
        {
            if (parentQuery == null)
            {
                throw new ArgumentNullException(nameof(parentQuery));
            }

            return(query.BuildOption(ParentQueryKey, parentQuery.Configure()));
        }
 /// <summary>
 /// Exposed only for testing purposes.
 /// </summary>
 public Task <FindResults <Employee> > GetByQueryAsync(RepositoryQueryDescriptor <Employee> query)
 {
     return(FindAsync(query));
 }
 /// <summary>
 /// This allows us easily test aggregations
 /// </summary>
 public Task <CountResult> GetCountByQueryAsync(RepositoryQueryDescriptor <Employee> query)
 {
     return(CountAsync(query));
 }
 public virtual Task <FindHit <T> > FindOneAsync(RepositoryQueryDescriptor <T> query, CommandOptionsDescriptor <T> options = null)
 {
     return(FindOneAsync(query.Configure(), options.Configure()));
 }
 public Task <bool> ExistsAsync(RepositoryQueryDescriptor <T> query)
 {
     return(ExistsAsync(query.Configure()));
 }
 public Task <bool> ExistsAsync(RepositoryQueryDescriptor <T> query, CommandOptionsDescriptor <T> options = null)
 {
     return(ExistsAsync(query.Configure(), options.Configure()));
 }