public void PopulateHousebreaks(Ticker ticker, List <HouseBreakReport> housebreakReport) { using (var bhavDBContext = new BhavCopiesDbEntities()) { foreach (HouseBreakReport hbr in housebreakReport) { Housebreak hb = CreateHousebreakObjectFromHBR(hbr, ticker); bhavDBContext.Housebreaks.Add(hb); } bhavDBContext.SaveChanges(); } }
private Housebreak CreateHousebreakObjectFromHBR(HouseBreakReport hbr, Ticker ticker) { Housebreak hb = new Housebreak(); hb.FK_Ticker_Id = ticker.Id; hb.MotherCandleHigh = hbr.MotherCandleHigh; hb.MotherCandleLow = hbr.MotherCandleLow; hb.MotherCandleDate = hbr.MotherCandleDate; hb.NumberOfCandles = hbr.NumberofCandles; hb.BreakoutCandleDate = hbr.BreakOutCandleDate; hb.Ticker = null; // BUG: if this is assigned ticker object, then it trys to //insert ticker row into tickers table. so made it null to fix return(hb); }