示例#1
0
 /// <summary>
 /// Returns an IQueryable document set for specified type
 /// </summary>
 /// <typeparam name="TDoc"></typeparam>
 /// <returns></returns>
 public virtual SanityDocumentSet <TDoc> DocumentSet <TDoc>()
 {
     lock (_dsLock)
     {
         if (!_documentSets.ContainsKey(typeof(TDoc)))
         {
             _documentSets[typeof(TDoc)] = new SanityDocumentSet <TDoc>(this);
         }
     }
     return(_documentSets[(typeof(TDoc))] as SanityDocumentSet <TDoc>);
 }
示例#2
0
        /// <summary>
        /// Returns an IQueryable document set for specified type
        /// </summary>
        /// <typeparam name="TDoc"></typeparam>
        /// <returns></returns>
        public virtual SanityDocumentSet <TDoc> DocumentSet <TDoc>(int maxNestingLevel = 7, bool excludeDocTypeConstraint = false)
        {
            var key = $"{typeof(TDoc)?.FullName ?? ""}_{maxNestingLevel}";

            lock (_dsLock)
            {
                if (!_documentSets.ContainsKey(key))
                {
                    _documentSets[key] = new SanityDocumentSet <TDoc>(this, maxNestingLevel, excludeDocTypeConstraint);
                }
            }
            return(_documentSets[key] as SanityDocumentSet <TDoc>);
        }
 public static Task <SanityDocumentResponse <SanityFileAsset> > UploadAsync(this SanityDocumentSet <SanityFileAsset> images, Uri uri, string label = null, CancellationToken cancellationToken = default)
 {
     return(images.Context.Client.UploadFileAsync(uri, label, cancellationToken));
 }
 public static Task <SanityDocumentResponse <SanityFileAsset> > UploadAsync(this SanityDocumentSet <SanityFileAsset> images, FileInfo file, string filename, string contentType = null, string label = null, CancellationToken cancellationToken = default)
 {
     return(images.Context.Client.UploadFileAsync(file, label, cancellationToken));
 }
 public static Task <SanityMutationResponse <TDoc> > CommitChangesAsync <TDoc>(this SanityDocumentSet <TDoc> docs, bool returnIds = false, bool returnDocuments = false, SanityMutationVisibility visibility = SanityMutationVisibility.Sync, CancellationToken cancellationToken = default)
 {
     return(docs.Context.CommitAsync <TDoc>(returnIds, returnDocuments, visibility, cancellationToken));
 }
 public static void ClearChanges <TDoc>(this SanityDocumentSet <TDoc> docs)
 {
     docs.Mutations.Clear();
 }
        //public static SanityTransactionBuilder<TDoc> PatchByQuery<TDoc>(this SanityDocumentSet<TDoc> docs, Expression<Func<TDoc,bool>> query, object patch)
        //{
        //    return docs.Mutations.PatchByQuery(query, patch);
        //}

        public static SanityMutationBuilder <TDoc> PatchByQuery <TDoc>(this SanityDocumentSet <TDoc> docs, Expression <Func <TDoc, bool> > query, Action <SanityPatch> patch)
        {
            return(docs.Mutations.PatchByQuery(query, patch));
        }
 public static SanityMutationBuilder <TDoc> PatchByQuery <TDoc>(this SanityDocumentSet <TDoc> docs, SanityPatchByQuery <TDoc> patch)
 {
     return(docs.Mutations.PatchByQuery(patch));
 }
        //public static SanityTransactionBuilder<TDoc> PatchById<TDoc>(this SanityDocumentSet<TDoc> docs, string id, object patch)
        //{
        //    return docs.Mutations.PatchById(id, patch);
        //}

        public static SanityMutationBuilder <TDoc> PatchById <TDoc>(this SanityDocumentSet <TDoc> docs, string id, Action <SanityPatch> patch)
        {
            return(docs.Mutations.PatchById(id, patch));
        }
 public static SanityMutationBuilder <TDoc> DeleteByQuery <TDoc>(this SanityDocumentSet <TDoc> docs, Expression <Func <TDoc, bool> > query)
 {
     return(docs.Mutations.DeleteByQuery(query));
 }
 public static SanityMutationBuilder <TDoc> DeleteById <TDoc>(this SanityDocumentSet <TDoc> docs, string id)
 {
     return(docs.Mutations.DeleteById(id));
 }
 public static SanityMutationBuilder <TDoc> Update <TDoc>(this SanityDocumentSet <TDoc> docs, TDoc document)
 {
     return(docs.Mutations.Update(document));
 }
 /// <summary>
 /// Sets only non-null values.
 /// </summary>
 /// <typeparam name="TDoc"></typeparam>
 /// <param name="docs"></param>
 /// <param name="document"></param>
 /// <returns></returns>
 public static SanityMutationBuilder <TDoc> SetValues <TDoc>(this SanityDocumentSet <TDoc> docs, TDoc document)
 {
     return(docs.Mutations.SetValues(document));
 }
示例#14
0
 public static Task <SanityDocumentResponse <SanityFileAsset> > UploadAsync(this SanityDocumentSet <SanityFileAsset> images, Uri uri, string label = null)
 {
     return(images.Context.Client.UploadFileAsync(uri, label));
 }
示例#15
0
 public static Task <SanityDocumentResponse <SanityFileAsset> > UploadAsync(this SanityDocumentSet <SanityFileAsset> images, Stream stream, string filename, string contentType = null, string label = null)
 {
     return(images.Context.Client.UploadFileAsync(stream, filename, contentType, label));
 }
示例#16
0
 public static Task <SanityDocumentResponse <SanityImageAsset> > UploadAsync(this SanityDocumentSet <SanityImageAsset> images, FileInfo file, string filename, string contentType = null, string label = null)
 {
     return(images.Context.Client.UploadImageAsync(file, label));
 }