Пример #1
0
 public static IStorageDbOptionsBuilder UseSqliteStorage <T>(this StorageDbOptionsBuilder options, string conn) where T : class
 {
     options.Services.AddDbContext <SqliteDbContext <T> >(o => o.UseSqlite(conn));
     options.Services.AddSingleton <ISqliteDbContext <T>, SqliteDbContext <T> >();
     options.Services.AddSingleton <IProvideRepository <T>, SqliteRepository <T> >();
     return(options);
 }
Пример #2
0
 public static IStorageDbOptionsBuilder UseCosmosDbStorage <T>(this StorageDbOptionsBuilder options,
                                                               string endpoint, string connKey,
                                                               string databaseId, string collectionId)
 {
     options.Services.AddSingleton(typeof(IProvideCosmosDbConnection <T>),
                                   p => new CosmosConnectionProvider <T>
                                   (
                                       endpoint, connKey, databaseId, collectionId
                                   ));
     options.Services.AddScoped(typeof(IProvideRepository <T>), typeof(DocumentDbRepository <T>));
     return(options);
 }