protected void Create_Click(object sender, EventArgs e) { using (var context = new FatDataContext()) { var code = CodeTextBox.Text; var existingStock = context.Stocks.Find(code); if (existingStock != null) { SetMessage("Stock {0} already exists.", code); return; } var newStock = context.Stocks.Create(); newStock.Code = code; newStock.CreatedUtcDate = DateTime.UtcNow; newStock.Industry = IndustryDropDownList.SelectedValue; newStock.IsActive = true; newStock.Name = NameTextBox.Text; context.Stocks.Add(newStock); context.SaveChanges(); SetMessage("Stock {0} created.", code); CodeTextBox.Text = ""; IndustryDropDownList.SelectedIndex = -1; NameTextBox.Text = ""; } }
public void AddQuotes(IEnumerable<StockQuote> quotes) { using (var context = new FatDataContext()) { foreach (var quote in quotes) { AddQuoteUncommited(context, quote); } context.SaveChanges(); } }
public void AddIndexQuotes(IEnumerable<IndexQuote> quotes) { // use own context for bulk insert using (var context = new FatDataContext()) { foreach (var quote in quotes) { AddIndexQuoteUncommited(context, quote); } context.SaveChanges(); } }
public void Add(IEnumerable<StockDividend> stockDividends) { // use own context for bulk insert using (var context = new FatDataContext()) { foreach (var dividend in stockDividends) { AddUncomitted(context, dividend); } context.SaveChanges(); } }
public void Add(IEnumerable<StockEarning> stockEarnings) { // use own context for bulk insert using (var context = new FatDataContext()) { foreach (var earning in stockEarnings) { AddUncomitted(context, earning); } context.SaveChanges(); } }