public static List <Rate> GetRateFromDBBackward(string pair, DateTime endDate, int barsCount, int minutesPerPriod) { return(GlobalStorage.UseForexContext(context => { IQueryable <t_Bar> bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate <= endDate) .OrderByDescending(b => b.StartDate).Take(barsCount); return GetRatesFromDBBars(bars); })); }
public static List <Rate> GetRateFromDB(string pair, DateTime startDate, int barsCount, int minutesPerBar) { return(GlobalStorage.UseForexContext(c => { var q = c.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerBar && b.StartDate >= startDate) .OrderBy(b => b.StartDate).Take(barsCount); return GetRatesFromDBBars(q); })); }
static List <TBar> GetRateFromDBForwardsInternal <TBar>(string pair, DateTimeOffset startDate, int barsCount, int minutesPerPriod) where TBar : BarBase, new() { return(GlobalStorage.UseForexContext(context => { var bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate >= startDate) .OrderBy(b => b.StartDate) .ThenBy(b => b.Row) .Take(barsCount); return GetRatesFromDbBars <TBar>(bars.ToList()); })); }
static List <TBar> GetRateFromDBBackwardsInternal <TBar>(string pair, DateTime endDate, int barsCount, int minutesPerPriod) where TBar : BarBase, new() { try { return(GlobalStorage.UseForexContext(context => { var bars = context.t_Bar .Where(b => b.Pair == pair && b.Period == minutesPerPriod && b.StartDate <= endDate) .OrderByDescending(b => b.StartDate) .Take(barsCount) .ToList() .OrderBy(b => b.StartDate) .ThenBy(b => b.Row); return GetRatesFromDbBars <TBar>(bars.ToList()); })); } catch (Exception exc) { throw new Exception(new { pair, endDate, barsCount, minutesPerPriod } +"", exc); } }