Esempio n. 1
0
        public IQueryable <T> GetQueryable()
        {
            var queryOptions = DocumentDBUtility.GetDocumentFeed <T>(Configuration);

            return(Context.CreateDocumentQuery <T>(queryOptions, new FeedOptions {
                EnableCrossPartitionQuery = true
            }));
        }
Esempio n. 2
0
        public async Task <T> UpsertAsync(T model)
        {
            var response = await Context.UpsertDocumentAsync(DocumentDBUtility.GetDocumentFeed <T>(Configuration), model);

            if (response.StatusCode.IsSuccessResponse())
            {
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        public async Task <bool> DeleteAsync(string id)
        {
            // DeleteDocumentAsync thows if the document link is invalid.
            // Get returns null so verify existence before calling delete.
            var exists = (await GetAsync(id)) != null;

            if (!exists)
            {
                return(false);
            }

            // Delete the requested account.
            var response = await Context.DeleteDocumentAsync(
                DocumentDBUtility.GetDocumentLink <T>(id, Configuration),
                new RequestOptions()
            {
                PartitionKey = new PartitionKey(id)
            });

            return(response.StatusCode.IsSuccessResponse());
        }
Esempio n. 4
0
 public Repository(IDocumentDBConfiguration configuration)
 {
     Configuration = configuration;
     Context       = DocumentDBUtility.NewDocumentClient(configuration);
 }