public async Task Cleanup() { CoreUnitOfWork.ClearTracker(); Wallet wallet1 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes( wallet => wallet.JMBG == "2904992785075", wallet => wallet.Transactions ); if (wallet1 != null) { await CoreUnitOfWork.WalletRepository.Delete(wallet1); await CoreUnitOfWork.SaveChangesAsync(); } Wallet wallet2 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes( wallet => wallet.JMBG == "2904990785034", wallet => wallet.Transactions ); if (wallet2 != null) { await CoreUnitOfWork.WalletRepository.Delete(wallet2); await CoreUnitOfWork.SaveChangesAsync(); } await DbContext.DisposeAsync(); DbContext = null; }
public async Task Cleanup() { CoreUnitOfWork.ClearTracker(); Wallet wallet = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes( wallet => wallet.JMBG == "1203977780011", wallet => wallet.Transactions ); if (wallet != null) { await CoreUnitOfWork.WalletRepository.Delete(wallet); await CoreUnitOfWork.SaveChangesAsync(); } Wallet wallet2 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes( wallet => wallet.JMBG == "1203008780011", wallet => wallet.Transactions ); if (wallet2 != null) { await CoreUnitOfWork.WalletRepository.Delete(wallet); await CoreUnitOfWork.SaveChangesAsync(); } await DbContext.DisposeAsync(); DbContext = null; }
public async Task Setup() { var dbContextFactory = new SampleDbContextFactory(); DbContext = dbContextFactory.CreateDbContext(new string[] { }); CoreUnitOfWork = new EfCoreUnitOfWork(DbContext); var firstBankService = new FirstBankService(); BankRoutingService = new BankRoutingService(firstBankService); FeeService = new FeeService(); var inMemorySettings = new Dictionary <string, string> { { "MaxDeposit", "1000000" }, { "MaxWithdraw", "100000" }, { "DaysAfterWalletCreationWithNoFee", "7" }, { "IsFirstTransferFreeInMonth", "True" }, { "FixedFee", "100" }, { "FeeLimit", "10000" }, { "PercentageFee", "1" } }; Configuration = new ConfigurationBuilder() .AddInMemoryCollection(inMemorySettings) .Build(); }
static void Main(string[] args) { using (var context = new EfCoreDbContext()) { var manageDb = new ManageDb(context); manageDb.AddBlog("Programing"); manageDb.AddBlog("Cooking"); manageDb.AddBlog("Sports"); //manageDb.AddBlog("Knygos"); manageDb.AddPost("C#", "All about CSharp programing", 1); manageDb.AddPost("dotNET", "All about dotNET programing", 1); manageDb.AddPost("Azure", "All about Azure", 1); Console.WriteLine("---------------------------------------"); manageDb.AddPost("Chicken", "All about chicken", 2); manageDb.AddPost("Vegan", "Vegan food recipes", 2); manageDb.AddPost("AsianKitchen", "Cook perfect asian dish", 2); Console.WriteLine("---------------------------------------"); manageDb.AddPost("Basketball", "Euroleague blog", 3); manageDb.AddPost("Football", "UEFA predictions", 3); manageDb.AddPost("Tennis", "Who will win Australian Open", 3); //////manageDb.RemovePost(); //manageDb.GetBlogs(); //manageDb.AddAuthor("Jonas", "Jonaitis", 1); //manageDb.AddAuthor("Agne", "Agnaite", 2); //manageDb.GetAuthors(); } }
public static void Initialize(EfCoreDbContext context) { var user = new User { UserName = "******", RealName = "admin", Salt = "123456", Password = ("123456".ToMd5() + "123456").ToMd5() }; var role = new Role { Name = "Admin", Description = "管理员" }; var userRole = new UserRole { User = user, Role = role }; var permission = new Permission { Name = "All", Description = "All", Role = role }; context.Users.Add(user); context.Roles.Add(role); context.UserRoles.Add(userRole); context.Permissions.Add(permission); context.SaveChanges(); }
public void SetUp() { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false, false) .Build(); _db = new EfCoreDbContext(configuration); }
public EfCoreQueryableTests() { _dbInitializer = new TestDbContextInitializer(); _dbContext = _dbInitializer.GetTestDbContext(); _efCoreDbContext = new EfCoreDbContext <TestDbContext>(_dbContext); SilverbackQueryableExtensions.Implementation = new EfCoreQueryableExtensions(); }
private EfCoreDbContext InitContext() { var options = new DbContextOptionsBuilder <EfCoreDbContext>() .UseInMemoryDatabase(databaseName: "test") .Options; var dbContext = new EfCoreDbContext(options); dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); return(dbContext); }
public void SetUp() { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false, false) .Build(); var conn = configuration.GetConnectionString("EfCoreDatabase"); var optionsBuilder = new DbContextOptionsBuilder <EfCoreDbContext>() .UseSqlServer(conn, x => x .UseNetTopologySuite() .UseHierarchyId()); _db = new EfCoreDbContext(optionsBuilder.Options); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, EfCoreDbContext db) { if (env.IsDevelopment()) { db.EnsureSeedData(); app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); }
public static List <ValidationResult> ExecuteValidation(this EfCoreDbContext context) { var result = new List <ValidationResult>(); foreach (var entry in context.ChangeTracker.Entries().Where(t => (t.State == EntityState.Added) || (t.State == EntityState.Modified))) { var entity = entry.Entity; var valProvider = new ValidationDbContextServiceProvider(context); var valContext = new ValidationContext(entity, valProvider, null); var entityErrors = new List <ValidationResult>(); if (!Validator.TryValidateObject( entity, valContext, entityErrors, true)) { result.AddRange(entityErrors); } } return(result.ToList()); }
public EfCoreUserRepository(EfCoreDbContext dbContext) : base(dbContext) { }
public SqlServerEfCore(EfCoreDbContext context) { this._dbContext = context; }
public EFCoreASyncRepository(EfCoreDbContext context) { this.context = context; }
public EfCoreRepository(EfCoreDbContext dbContext) { _dbContext = dbContext; }
public BenutzerRepository(EfCoreDbContext dbContext) : base(dbContext) { }
public Repository(IServiceProvider serviceProvider) { _context = (EfCoreDbContext)serviceProvider.GetService(typeof(EfCoreDbContext)); }
public OrderController(EfCoreDbContext context) { _context = context; }
public EfCoreGroupRepository(EfCoreDbContext dbContext) : base(dbContext) { }
public EfCoreUnitOfWork(EfCoreDbContext context) { Context = context; WalletRepository = new WalletRepository(context); }
public UnitOfWork(EfCoreDbContext context) { _dbContext = context ?? throw new ArgumentNullException("ef core dbcontext can not as null"); }
public CustomersController(EfCoreDbContext context) { _context = context; }
public Repository(IUnitOfWork unit) { _dbContext = unit.DbContext; }
public EFCoreProcedureRepository(EfCoreDbContext context) { this.context = context; }
public EfCoreDbContextTests() { _dbInitializer = new TestDbContextInitializer(); _dbContext = _dbInitializer.GetTestDbContext(); _efCoreDbContext = new EfCoreDbContext <TestDbContext>(_dbContext); }
public EfCoreRepository(EfCoreDbContext context) { _context = context; DbSet = context.Set <TEntity>(); }
protected EfCoreRepositoryBase() { _dbContext = new EfCoreDbContext(); }
protected BaseEfCoreTests(DatabaseFixture fixture) { Context = new EfCoreDbContext(fixture.Options); }
public WalletRepository(EfCoreDbContext context) : base(context) { }
public ManageDb(EfCoreDbContext context) { _context = context; _context.Database.EnsureCreated(); }