public void AddCandles(ChartEntryEntity entry, DateTime from, DateTime to, Candle[] candles) { FetchHistories.RemoveRange(FetchHistories .Where( history => history.ChartEntry.Id == entry.Id && history.From >= from && history.To <= to)); FetchHistories.Add(new CandleFetchHistory() { ChartEntry = entry, From = from, To = to, FetchCount = candles.Length }); Candles.RemoveRange(Candles .Where( candle => candle.ChartEntry.Id == entry.Id && candle.Time >= from && candle.Time <= to)); Candles.AddRangeAsync( candles.Select(candle => new CandleEntity() { ChartEntry = entry, Time = candle.Time, Open = candle.Open, High = candle.High, Low = candle.Low, Close = candle.Close, Volume = candle.Volume })); SaveChangesAsync(); }