public virtual TDocument Get(Guid documentId) { using (var ctx = dbContextFactory.Get()) { return(ctx.Set <TDocument>().FirstOrDefault(x => x.GUID == documentId)); } }
public async Task CreateAsync(OdissUser user) { using (var ctx = dbContextFactory.Get()) { ctx.Set <OdissUser>().Add(user); await ctx.SaveChangesAsync(); } }
public Repository(IDbContextFactory dbContextFactory, EventBag eventBag, IBoltOnClock boltOnClock) { DbContext = dbContextFactory.Get <TDbContext>(); DbSets = DbContext.Set <TEntity>(); _eventBag = eventBag; _boltOnClock = boltOnClock; }
public async Task <Guid> CreateProductAsync(ProductCreateViewModel viewModel) { var newProduct = new Models.Product { Id = Guid.NewGuid(), Name = viewModel.Name, Description = viewModel.Description }; using (var dbContext = _productContext.Get()) { dbContext.Products.Add(newProduct); await dbContext.SaveChangesAsync(); return(newProduct.Id); } }
public async Task <Model> GetMemberList(CancellationToken cancelToken, int clientId) { using (var dbContext = _dbFactory.Get(clientId)) { // Code Goes Here.... } return(null); }
// We're doing it this way to avoid creating a dependency on IServiceEngine for Octacom.Search.EF // A contract should not be dependent on a specific implementation, otherwise its purpose is defeated public override Contracts.Repositories.Searching.SearchResult <TDocumentResult> Search(IDictionary <string, object> searchParameters = null, int page = 1, int?pageSize = null, IDictionary <string, Contracts.Repositories.Searching.SortOrder> sortings = null) { using (var ctx = dbContextFactory.Get()) { var results = Search(ctx, searchParameters, page, pageSize, SearchHelper.MapSortings(sortings), x => x.GUID); return(SearchHelper.MapSearchResults(results)); } }
// We're doing it this way to avoid creating a dependency on IServiceEngine for Octacom.Search.EF // A contract should not be dependent on a specific implementation, otherwise its purpose is defeated public virtual Contracts.Repositories.Searching.SearchResult <TEntity> Search(IDictionary <string, object> searchParameters = null, int page = 1, int?pageSize = null, IDictionary <string, Contracts.Repositories.Searching.SortOrder> sortings = null) { using (var ctx = dbContextFactory.Get()) { var results = Search <TEntity>(ctx, searchParameters, page, pageSize, SearchHelper.MapSortings(sortings), null); return(SearchHelper.MapSearchResults(results)); } }
public static void DropDb <T>(IDbContextFactory <T> dbContextFactory) where T : DbContext { if (!dbContextFactory.IsOpen()) { dbContextFactory.Open(); } dbContextFactory.Get().Database.EnsureDeleted(); dbContextFactory.Close(); }
protected BaseEFRepository(IDbContextFactory dbContextFactory) { _dbContext = dbContextFactory.Get <TDbContext>(); _dbSets = _dbContext.Set <TEntity>(); }
public BaseRepository(IDbContextFactory <SgaContext> contextFactory) { Context = contextFactory.Get(); DbSet = Context.Set <TEntity>(); }