public static void SetStoredProcedureHandler <T>(this ICosmosDbRepository <T> self, string id, Func <object[], RequestOptions, Task <object> > func) { if (self is null) { throw new ArgumentNullException(nameof(self)); } if (!(self is CosmosDbRepositorySubstitute <T> substitute)) { throw new ArgumentException($"self is not a CosmosDbRepositorySubstituteBase<{typeof(T).Name}>", nameof(self)); } substitute.SetStoredProcedureHandler(id, func); }
public static void ClearGenerateExceptionOnCount <T>(this ICosmosDbRepository <T> self) { if (self is null) { throw new ArgumentNullException(nameof(self)); } if (!(self is CosmosDbRepositorySubstitute <T> substitute)) { throw new ArgumentException($"self is not a CosmosDbRepositorySubstituteBase<{typeof(T).Name}>", nameof(self)); } substitute.ClearGenerateExceptionOnCount(); }
public static void GenerateExceptionOnAddWhen <T>(this ICosmosDbRepository <T> self, Predicate <T> predicate, HttpStatusCode statusCode, string message = default) { if (self is null) { throw new ArgumentNullException(nameof(self)); } if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } if (!(self is CosmosDbRepositorySubstitute <T> substitute)) { throw new ArgumentException($"self is not a CosmosDbRepositorySubstituteBase<{typeof(T).Name}>", nameof(self)); } substitute.GenerateExceptionOnAddWhen(predicate, statusCode, message); }
public TestingContext(IServiceProvider services, Action <ICosmosDbBuilder> builderCallback, Action <ICosmosDbRepositoryBuilder <T> > repoBuilderCallback) { DbConfig = services.GetRequiredService <IOptions <CosmosDbConfig> >().Value; TestConfig = services.GetRequiredService <IOptions <TestConfig> >().Value.Clone(); EnvConfig = services.GetRequiredService <IOptions <EnvironmentConfig> >().Value; if (EnvConfig.RandomizeCollectionName) { TestConfig.CollectionName = $"{TestConfig.CollectionName}{Guid.NewGuid()}"; } DbClient = new DocumentClient(new Uri(DbConfig.DbEndPoint), DbConfig.DbKey); var builder = new CosmosDbBuilder() .WithId(DbConfig.DbName) .WithDefaultThroughput(400) .AddCollection <T>(TestConfig.CollectionName, repoBuilderCallback); builderCallback?.Invoke(builder); CosmosDb = builder.Build(DbClient); Repo = CosmosDb.Repository <T>(); }
public static Task <IList <U> > SelectManyAsync <T, U, V>(this ICosmosDbRepository <T> repo, V partitionKey, Expression <Func <T, IEnumerable <U> > > selector, Func <IQueryable <T>, IQueryable <T> > whereClauses = null, Func <IQueryable <U>, IQueryable <U> > selectClauses = null, FeedOptions feedOptions = null) { feedOptions = SetPartitionKey(partitionKey, feedOptions); return(repo.SelectManyAsync(selector, whereClauses, selectClauses, feedOptions)); }
public static Task <T> UpsertAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, T entity, RequestOptions requestOptions = null) { requestOptions = SetPartitionKey(partitionKey, requestOptions); return(repo.ReplaceAsync(entity, requestOptions)); }
public static Task <CosmosDbRepositoryPagedResults <T> > FindAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, int pageSize, string continuationToken, Expression <Func <T, bool> > predicate = null, Func <IQueryable <T>, IQueryable <T> > clauses = null, FeedOptions feedOptions = null) { feedOptions = SetPartitionKey(partitionKey, feedOptions); return(repo.FindAsync(pageSize, continuationToken, predicate, clauses, feedOptions)); }
public Queue(ICosmosDb cosmosDb) { _queueRepository = cosmosDb.Repository <QueueDocument>(); }
public TokenContainer(ICosmosDbRepository storgeRepository) { _container = storgeRepository.GetContainer(nameof(ContainerName.AccoTokens)); }
public static Task <T> GetAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, DocumentId itemId, RequestOptions requestOptions = null) { requestOptions = SetPartitionKey(partitionKey, requestOptions); return(repo.GetAsync(itemId, requestOptions)); }
public AuthorizeService(IConfiguration config, ICosmosDbRepository <Admin> repository) { _config = config; _repository = repository; }
public FoodTruckController(ICosmosDbRepository <FoodTruck> repo, ILogger <FoodTruckController> logger) { _repo = repo ?? throw new ArgumentNullException(nameof(repo)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public OfficesController(ICosmosDbRepository <Office> repository) { _repository = repository; }
public TestingSubstituteContext(Func <T, object> partionkeySelector, bool?partitioned) { Repo = new CosmosDbRepositorySubstitute <T>(partionkeySelector, partitioned); }
/// <summary> /// Initializes a new instance of the <see cref="FoodTruckProvider"/> class. /// </summary> /// <param name="csvRepository">The CSV repository.</param> /// <param name="cosmosDbRepository">The cosmos database repository.</param> public FoodTruckProvider(ICsvRepository csvRepository, ICosmosDbRepository cosmosDbRepository) { _csvRepository = csvRepository; _cosmosDbRepository = cosmosDbRepository; }
public HfeaFormValidationService(ICosmosDbRepository <HfeaForm> hfeaRepository) { _hfeaRepository = hfeaRepository; }
public PrintersController(ICosmosDbRepository <Printer> repository) { _repository = repository; }
public DesksController(ICosmosDbRepository <Desk> repository) { _repository = repository; }
public static Task <CosmosDbRepositoryPagedResults <U> > SelectManyAsync <T, U, V>(this ICosmosDbRepository <T> repo, V partitionKey, int pageSize, string continuationToken, Expression <Func <T, IEnumerable <U> > > selector, Func <IQueryable <T>, IQueryable <T> > whereClauses = null, Func <IQueryable <U>, IQueryable <U> > selectClauses = null, FeedOptions feedOptions = null) { feedOptions = SetPartitionKey(partitionKey, feedOptions); return(repo.SelectManyAsync(pageSize, continuationToken, selector, whereClauses, selectClauses, feedOptions)); }
public static Task <bool> DeleteDocumentAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, T entity, RequestOptions requestOptions = null) { requestOptions = SetPartitionKey(partitionKey, requestOptions); return(repo.DeleteDocumentAsync(entity, requestOptions)); }
public static Task <T> FindFirstOrDefaultAsync <T, U>(this ICosmosDbRepository <T> repo, U partitionKey, Expression <Func <T, bool> > predicate = null, Func <IQueryable <T>, IQueryable <T> > clauses = null, FeedOptions feedOptions = null) { feedOptions = SetPartitionKey(partitionKey, feedOptions); return(repo.FindFirstOrDefaultAsync(predicate, clauses, feedOptions)); }
public StoreProcedureImpl(IDocumentClient client, ICosmosDbRepository repository, string id) { Client = client; StoredProcUri = new AsyncLazy <Uri>(() => GetStoredProcUri(repository, id)); }
public Stores(ICosmosDb cosmosDb) { _storeRepository = cosmosDb.Repository <StoreDocument>(); }
public TestingSubstituteContext() { Repo = new CosmosDbRepositorySubstitute <T>(); }
public GuestsController(ICosmosDbRepository <Guest> repository) { _repository = repository; }
public static Task <int> CrossPartitionCountAsync <T>(this ICosmosDbRepository <T> repo, Expression <Func <T, bool> > predicate = null, Func <IQueryable <T>, IQueryable <T> > clauses = null, FeedOptions feedOptions = null) { feedOptions = SetCrossPartition(feedOptions); return(repo.CountAsync(predicate, clauses, feedOptions)); }
public static Task <IList <U> > CrossPartitionSelectAsync <T, U, V>(this ICosmosDbRepository <T> repo, Expression <Func <V, U> > selector, Func <IQueryable <T>, IQueryable <V> > whereClauses = null, Func <IQueryable <U>, IQueryable <U> > selectClauses = null, FeedOptions feedOptions = null) { feedOptions = SetCrossPartition(feedOptions); return(repo.SelectAsync(selector, whereClauses, selectClauses, feedOptions)); }
public RoomsController(ICosmosDbRepository <Room> repository) { _repository = repository; }
private async Task <Uri> GetStoredProcUri(ICosmosDbRepository repository, string id) { return(new Uri($"{await repository.AltLink}/sprocs/{Uri.EscapeUriString(id)}", UriKind.Relative)); }
public static Task <CosmosDbRepositoryPagedResults <U> > CrossPartitionSelectAsync <T, U, V>(this ICosmosDbRepository <T> repo, int pageSize, string continuationToken, Expression <Func <V, U> > selector, Func <IQueryable <T>, IQueryable <V> > whereClauses, Func <IQueryable <U>, IQueryable <U> > selectClauses = null, FeedOptions feedOptions = null) { feedOptions = SetCrossPartition(feedOptions); return(repo.SelectAsync(pageSize, continuationToken, selector, whereClauses, selectClauses, feedOptions)); }