internal SanityMutationBuilder <TDoc> DeleteByQuery(Expression query)
        {
            var parser      = new SanityExpressionParser(query, typeof(TDoc));
            var sanityQuery = parser.BuildQuery(false);

            DeleteByQuery(sanityQuery);
            return(this);
        }
        public SanityMutationBuilder <TDoc> DeleteByQuery(Expression <Func <TDoc, bool> > query)
        {
            var parser      = new SanityExpressionParser(query, typeof(TDoc));
            var sanityQuery = parser.BuildQuery(false);

            DeleteByQuery(sanityQuery);
            return(this);
        }
示例#3
0
        internal SanityMutationBuilder <TDoc> DeleteByQuery(Expression query)
        {
            var parser      = new SanityExpressionParser(query, typeof(TDoc), MutationQuerySettings.MAX_NESTING_LEVEL);
            var sanityQuery = parser.BuildQuery(false);

            DeleteByQuery(sanityQuery);
            return(this);
        }
示例#4
0
        public SanityPatchByQuery(Expression query) : base()
        {
            if (query == null)
            {
                throw new ArgumentException("Query field must be set", nameof(query));
            }

            var parser      = new SanityExpressionParser(query, typeof(TDoc), MutationQuerySettings.MAX_NESTING_LEVEL);
            var sanityQuery = parser.BuildQuery();

            Query = sanityQuery;
        }
示例#5
0
        public SanityPatchByQuery(Expression <Func <TDoc, bool> > query) : base()
        {
            if (query == null)
            {
                throw new ArgumentException("Query field must be set", nameof(query));
            }

            var parser      = new SanityExpressionParser(query, typeof(TDoc));
            var sanityQuery = parser.BuildQuery();

            Query = sanityQuery;
        }
        //public SanityTransactionBuilder<TDoc> PatchByQuery(Expression<Func<TDoc, bool>> query, object patch)
        //{
        //    lock (GetLock())
        //    {
        //        var sPatch = JsonConvert.SerializeObject(patch);
        //        var oPatch = JsonConvert.DeserializeObject<SanityPatchByQuery<TDoc>>(sPatch);
        //        var parser = new SanityExpressionParser(query, typeof(TDoc));
        //        var sQuery = parser.BuildQuery();
        //        oPatch.Query = sQuery;
        //        InnerBuilder.Mutations.Add(new SanityPatchMutation(oPatch) { DocType = typeof(TDoc) });
        //        return this;
        //    }
        //}

        public SanityMutationBuilder <TDoc> PatchByQuery(Expression <Func <TDoc, bool> > query, Action <SanityPatch> patch)
        {
            lock (GetLock())
            {
                var oPatch = new SanityPatchByQuery <TDoc>(query);
                patch.Invoke(oPatch);
                var parser = new SanityExpressionParser(query, typeof(TDoc));
                InnerBuilder.Mutations.Add(new SanityPatchMutation(oPatch)
                {
                    DocType = typeof(TDoc)
                });
                return(this);
            }
        }