public String Initialize() { using (var context = new StockExchangeDbContext()) { new StockExchangeDbInitializer().InitializeDatabase(context); return "Database Initialized"; } }
public static void InsertCountryExchange(Country country, List <string> exchanges) { using (var context = new StockExchangeDbContext()) { context.Countries.Add(country); context.SaveChanges(); int countryId = country.CountryId; List <Exchange> newExchanges = new List <Exchange>(); foreach (var exchange in exchanges) { newExchanges.Add(new Exchange { Name = exchange, CountryId = countryId }); } context.Exchanges.AddRange(newExchanges); context.SaveChanges(); } }
public UnitOfWork() { StockExchangeDbContext = new StockExchangeDbContext(); Stocks = new StockRepository(StockExchangeDbContext); Exchanges = new ExchangeRepository(StockExchangeDbContext); }
public int SaveChanges() { return(StockExchangeDbContext.SaveChanges()); }
public void Dispose() { StockExchangeDbContext.Dispose(); }
public ExchangeRepository(StockExchangeDbContext context) : base(context) { Context = context; }
public static void InsertCompanies(Company company) { using (var context = new StockExchangeDbContext()) { context.Database.ExecuteSqlInterpolated(@$ "EXEC dbo.InsertCompany @Isin={company.Isin}, @Name={company.Name}, @Sector={company.Sector.Name}, @Industry={company.Industry.Name}, @EquityType={company.EquityType.Name},