public void Add(DbContextBase dbCtx, object e) { if (dbCtx.Entry(e).State != EntityState.Modified) { dbCtx.Entry(e).State = EntityState.Added; } }
public void Update(DbContextBase dbCtx, object e) { var type = e.GetType(); if (_typesToExclude.Any(t => t.IsAssignableFrom(type))) { var pi = type.GetProperty(_propertyName); if (pi != null) { dbCtx.Entry(e).OriginalValues[_propertyName] = pi.GetValue(e); } } _entityUpdater.Update(dbCtx, e); }
public void Action(DbContextBase context) { var orders = new List<Order> { new Order { OrderNo = SequenceNoUtils.GenerateNo('O'), OrderAmount = 10000, ProductNo = "PN1001", UserNo = "UID1001" }, new Order { OrderNo = SequenceNoUtils.GenerateNo('O'), OrderAmount = 10000, ProductNo = "PN1001", UserNo = "UID1001" }, new Order { OrderNo = SequenceNoUtils.GenerateNo('O'), OrderAmount = 10000, ProductNo = "PN1001", UserNo = "UID1001" }, new Order { OrderNo = SequenceNoUtils.GenerateNo('O'), OrderAmount = 10000, ProductNo = "PN1001", UserNo = "UID1001" } }; orders.ForEach(context.Add); }
/// <summary> /// /// </summary> /// <param name="dbContextBase"></param> /// <param name="dbContextFactory"></param> protected EntityFrameworkCoreFactoryRepositoryAsync(DbContextBase dbContextBase, IDbContextFactory <TDbContext> dbContextFactory) : base(dbContextBase) { _dbContextFactory = dbContextFactory; _contexts = new List <TDbContext>(); }
public UnitOfWork(TDbContext dbContext) { _dbContext = dbContext as DbContextBase; }
public void Setup() { _dbContext = FakeDbContext.GetInstance(); _service = new VictimRepository(_dbContext); }
protected EfGenericRepositoryBase(DbContextBase dbContext) : base(dbContext) { }
public RepositoryBase(DbContextBase dbContext) { DbContext = dbContext; DbSet = DbContext.Set <TEntity>(); }
public FormRepository(DbContextBase db) { this.db = db; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, DbContextBase dbContextBase) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Details of the problem of the (Exception Handler). app.UseProblemDetailsExceptionHandlerConfiguration(loggerFactory); // Middleware that uses Serilog to log requests to Endpoints. app.UseSerilogRequestLogging(); // Use initial database configurations. app.UseDatabaseConfiguration(env, dbContextBase); // Serve the static photos of registered users. app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "StaticFiles/photos")), OnPrepareResponse = ctx => { ctx.Context.Response.Headers.Append("Cache-Control", "public, max-age=666"); }, RequestPath = "/static/photos" }); // Serve static files. app.UseFileServer(new FileServerOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "StaticFiles/public")), EnableDirectoryBrowsing = true, RequestPath = "/web", }); app.UseRouting(); app.UseCors(crossOriginRequest => { crossOriginRequest.WithMethods("OPTIONS", "GET", "POST", "PUT", "DELETE", "PATCH"); crossOriginRequest.AllowAnyOrigin(); crossOriginRequest.AllowAnyHeader(); crossOriginRequest.WithExposedHeaders("x-perpro", "Cache-control", "Pragma", "x-hubin-info"); }); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { await context.Response.WriteAsync($" Hello World! Environment({env.EnvironmentName})"); }); endpoints.MapControllers(); }); }
/// <summary> /// /// </summary> /// <param name="aggregates"></param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task AddRangeAsync(IEnumerable <TAggregateRoot> aggregates, CancellationToken cancellationToken) { return(DbContextBase.SetAggregate <TAggregateRoot>().AddRangeAsync(aggregates, cancellationToken)); }
/// <summary> /// /// </summary> /// <param name="aggregateRoot"></param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task AddAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken) { return(DbContextBase.SetAggregate <TAggregateRoot>().AddAsync(aggregateRoot, cancellationToken).AsTask()); }
public EntityRepository(DbContextBase dbContext) { this.dbContext = dbContext; this.DbSet = this.dbContext.Set <TEntity>(); }
public EventRepository(DbContextBase dbContext) : base(dbContext) { }
public CountryRepository(DbContextBase dbContext) : base(dbContext) { }
public ProjectRepository(DbContextBase context) : base(context) { }
public TypeBurialRepository(DbContextBase db) { this.db = db; }
public BirthPlaceRepository(DbContextBase db) { this.db = db; }
public void Setup() { _dbContext = FakeDbContext.GetInstance(); _service = new AttachmentBurialRepository(_dbContext); }
/// <summary> /// /// </summary> /// <param name="aggregateRoot"></param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public Task RemoveAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken) { DbContextBase.SetAggregate <TAggregateRoot>().Remove(aggregateRoot); return(TaskHelper.CompletedTask); }
public Task AfterSaveChangesAsync(DbContextBase dbContextBase) { return(Task.CompletedTask); }
/// <summary> /// /// </summary> /// <param name="aggregateRoot"></param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task UpdateAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken) { DbContextBase.SetAggregate <TAggregateRoot>().Update(aggregateRoot); return(TaskHelper.CompletedTask); }
public ConscriptionPlaceRepository(DbContextBase db) { this.db = db; }
/// <summary> /// /// </summary> /// <param name="aggregates"></param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task UpdateRangeAsync(IEnumerable <TAggregateRoot> aggregates, CancellationToken cancellationToken) { DbContextBase.SetAggregate <TAggregateRoot>().UpdateRange(aggregates); return(TaskHelper.CompletedTask); }
public void Setup() { _dbContext = FakeDbContext.GetInstance(); _service = new BirthPlaceRepository(_dbContext); }
/// <summary> /// /// </summary> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task <int> RollbackAsync(CancellationToken cancellationToken) { return(DbContextBase.RollbackAsync(cancellationToken)); }
public RoleRepository(DbContextBase db) { this.db = db; }
/// <summary> /// /// </summary> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task <int> SaveChangesAsync(CancellationToken cancellationToken) { return(DbContextBase.SaveChangesAsync(cancellationToken)); }
public AttachmentFormRepository(DbContextBase db) { this.db = db; }
public EfUnitOfWork(IDbContextAccessor dbContextAccessor) { _dbContext = dbContextAccessor.Context; }
/// <summary> /// /// </summary> /// <param name="dbContextBase"></param> protected EntityFrameworkCoreRepositoryAsync(DbContextBase dbContextBase) : base(dbContextBase) { }
public DbContextAccessor(DbContextBase context) { Context = context; }
public void Detach(DbContextBase dbCtx, object e) { dbCtx.Entry(e).State = EntityState.Detached; }
/// <summary> /// /// </summary> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns></returns> public virtual Task <int> CountAsync(CancellationToken cancellationToken) { return(DbContextBase.SetAggregate <TAggregateRoot>().CountAsync(cancellationToken)); }