public async Task <MarketPaper> GetIncludePriceAsync(DateTime b, DateTime e, PaperPriceType type, string code) { var paper = await DbContext.Set <MarketPaper>() .SingleAsync(x => x.Code == code); if (type == PaperPriceType.Day) { var price = await DbContext.Set <PaperDayPricePoint>() .Where(x => x.Date >= b && x.Date <= e).ToListAsync(); } return(paper); }
public async Task <List <MarketPaper> > GetAllIncludePriceAsync(DateTime b, DateTime e, PaperPriceType type) { var paper = await DbContext.Set <MarketPaper>().ToListAsync(); List <PaperPricePoint> price = null; if (type == PaperPriceType.Day) { price = await DbContext.Set <PaperDayPricePoint>() .AsNoTracking() .Where(x => x.Date >= b && x.Date <= e) .Select(x => new PaperPricePoint(x.Code, x.Date, new PaperPrice(x.Price.Close))) .ToListAsync(); } else if (type == PaperPriceType.Week) { price = await DbContext.Set <PaperWeekPricePoint>() .AsNoTracking() .Where(x => x.Date >= b && x.Date <= e) .Select(x => new PaperPricePoint(x.Code, x.Date, new PaperPrice(x.Price.Close))) .ToListAsync(); } SetPaperPrice(paper, price); return(paper); }