Esempio n. 1
0
 public virtual TDocument Get(Guid documentId)
 {
     using (var ctx = dbContextFactory.Get())
     {
         return(ctx.Set <TDocument>().FirstOrDefault(x => x.GUID == documentId));
     }
 }
Esempio n. 2
0
        public async Task CreateAsync(OdissUser user)
        {
            using (var ctx = dbContextFactory.Get())
            {
                ctx.Set <OdissUser>().Add(user);

                await ctx.SaveChangesAsync();
            }
        }
Esempio n. 3
0
 public Repository(IDbContextFactory dbContextFactory, EventBag eventBag,
                   IBoltOnClock boltOnClock)
 {
     DbContext    = dbContextFactory.Get <TDbContext>();
     DbSets       = DbContext.Set <TEntity>();
     _eventBag    = eventBag;
     _boltOnClock = boltOnClock;
 }
Esempio n. 4
0
        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);
    }
Esempio n. 6
0
        // 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));
            }
        }
Esempio n. 8
0
        public static void DropDb <T>(IDbContextFactory <T> dbContextFactory) where T : DbContext
        {
            if (!dbContextFactory.IsOpen())
            {
                dbContextFactory.Open();
            }

            dbContextFactory.Get().Database.EnsureDeleted();
            dbContextFactory.Close();
        }
Esempio n. 9
0
 protected BaseEFRepository(IDbContextFactory dbContextFactory)
 {
     _dbContext = dbContextFactory.Get <TDbContext>();
     _dbSets    = _dbContext.Set <TEntity>();
 }
Esempio n. 10
0
 public BaseRepository(IDbContextFactory <SgaContext> contextFactory)
 {
     Context = contextFactory.Get();
     DbSet   = Context.Set <TEntity>();
 }