private void ExcecuteExternalSqlFiles(DbContextOptionsBuilder <PDXContext> options) { var currentPath = Directory.GetCurrentDirectory(); var path = currentPath.Replace("pdx.dal\\bin\\Debug\\netcoreapp1.1", "pdx.dal") + "\\Views"; DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] files = dir.GetFiles("*.sql"); using (var context = new PDXContext(options.Options)) { foreach (var file in files) { var script = string.Join(" ", File.ReadAllLines(file.FullName)); using (var connection = context.Database.GetDbConnection()) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = script; var result = command.ExecuteScalar().ToString(); } } } } }
public GenericRepository(PDXContext dbContext, PDX.Logging.ILogger logger) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _dbSet = _dbContext.Set <T>(); _logger = logger; _includes = DbContextHelper.GetNavigations <T>(); }
public UnitOfWork(PDXContext context, PDX.Logging.ILogger logger) { _context = context; _logger = logger; _repositoryDict = new Dictionary <string, object>(); var dbSetTypes = _context.GetAllDbSetTypes(); InitializeRepositories(dbSetTypes); }
public ImportPermitRepository(PDXContext dbContext, ILogger logger) : base(dbContext, logger) { }
public MARepository(PDXContext context, ILogger logger) : base(context, logger) { }
public ProductRepository(PDXContext dbContext, ILogger logger) : base(dbContext, logger) { }
protected override void Up(MigrationBuilder migrationBuilder) { DbContextOptionsBuilder <PDXContext> options = new DbContextOptionsBuilder <PDXContext>(); options.UseNpgsql(connectionString); //Delete existing records using (var context = new PDXContext(options.Options)) { //Account context.MenuRoles.Clear(); context.UserRoles.Clear(); context.Menus.Clear(); context.Roles.Clear(); context.Users.Clear(); //Customer context.Agents.Clear(); context.UserAgents.Clear(); context.Manufacturers.Clear(); //Commodity context.Products.Clear(); context.ProductManufacturers.Clear(); //Document context.ModuleDocuments.Clear(); context.LetterHeadings.Clear(); context.Letters.Clear(); //Lookups context.PaymentModes.Clear(); context.ShippingMethods.Clear(); context.PortOfEntries.Clear(); context.Currencies.Clear(); context.Countries.Clear(); context.Addresses.Clear(); context.AgentTypes.Clear(); context.DocumentTypes.Clear(); context.Modules.Clear(); context.CommodityTypes.Clear(); context.ImportPermitStatuses.Clear(); context.ImportPermitDeliveries.Clear(); context.UserTypes.Clear(); context.AgentLevels.Clear(); context.SaveChanges(); } //Re Insert Records using (var context = new PDXContext(options.Options)) { //lookups context.UserTypes.AddRange(GetUserTypes()); context.PaymentModes.AddRange(GetPaymentModes()); context.ShippingMethods.AddRange(GetShippingMethods()); context.PortOfEntries.AddRange(GetPortOfEntries()); context.Currencies.AddRange(GetCurrencies()); context.Countries.AddRange(GetCountries()); context.Addresses.AddRange(GetAddresses()); context.AgentTypes.AddRange(GetAgentTypes()); context.DocumentTypes.AddRange(GetDocumentTypes()); context.Modules.AddRange(GetModules()); context.CommodityTypes.AddRange(GetCommodityTypes()); context.ImportPermitStatuses.AddRange(GetImportPermitStatus()); context.ImportPermitDeliveries.AddRange(GetImportPermitDeliveries()); context.AgentLevels.AddRange(GetAgentLevels()); //Account context.Roles.AddRange(GetRoles()); context.Menus.AddRange(GetMenus()); context.MenuRoles.AddRange(GetMenuRoles()); context.Users.AddRange(GetUsers()); context.UserRoles.AddRange(GetUserRoles()); //Customer context.Agents.AddRange(GetAgents()); context.UserAgents.AddRange(GetUserAgents()); context.Manufacturers.AddRange(GetManufacturers()); //Commodity context.Products.AddRange(GetProducts()); context.ProductManufacturers.AddRange(GetProductManufacturers()); //Document context.ModuleDocuments.AddRange(GetModuleDocuments()); context.LetterHeadings.AddRange(GetLetterHeadings()); context.Letters.AddRange(GetLetters()); context.SaveChanges(); //Excecute Views //ExcecuteExternalSqlFiles(options); } }
public UserRepository(PDXContext dbContext, ILogger logger) : base(dbContext, logger) { }