public Domain.Stock FindBySymbol(string stockSymbol) { using (FhQuotesContext ctx = new FhQuotesContext()) { return(ctx.Stocks.Find(stockSymbol).ToDomain()); } }
public ICollection <string> FindAllSymbols() { using (FhQuotesContext ctx = new FhQuotesContext()) { return(ctx.Stocks.Select(stock => stock.Symbol).ToList()); } }
public ICollection <Domain.Stock> FindAll() { using (FhQuotesContext ctx = new FhQuotesContext()) { // First materialize then convert to doamin model !!!! return(ctx.Stocks.AsEnumerable().Select(stock => stock.ToDomain()).ToList()); } }
public Domain.Quote FindLastQuote(string stockSymbol) { using (FhQuotesContext ctx = new FhQuotesContext()) { return(ctx.Quotes.Where(quote => quote.Stock.Symbol.Equals(stockSymbol)) .OrderByDescending(q => q.Time) .FirstOrDefault().ToDomain()); } }
public ICollection <Domain.Quote> FindQuotesInRange(string stockSymbol, DateTime from, DateTime to) { using (FhQuotesContext ctx = new FhQuotesContext()) { return(ctx.Quotes.Where(q => q.Stock.Symbol.Equals(stockSymbol)) .Where(q => q.Time.CompareTo(from) >= 0) .Where(q => q.Time.CompareTo(to) <= 0) .OrderByDescending(q => q.Time) .AsEnumerable().Select(q => q.ToDomain()) .ToList()); } }
public bool Insert(Domain.Stock stock) { using (FhQuotesContext ctx = new FhQuotesContext()) { if (ctx.Stocks.Find(stock.Symbol) == null) { ctx.Stocks.Add(stock.ToEF()); ctx.SaveChanges(); return(true); } return(false); } }
public bool Insert(string stockSymbol, Domain.Quote quote) { using (FhQuotesContext ctx = new FhQuotesContext()) { Stock stock = ctx.Stocks.Find(stockSymbol); if (stock == null) { return(false); } var quoteEF = quote.ToEF(); quoteEF.Stock = stock; ctx.Quotes.Add(quoteEF); ctx.SaveChanges(); return(true); } }
public DbInitializer(FhQuotesContext context) { this.Context = context; }
public QuoteDao(FhQuotesContext context) { this.context = context; }
public StockDao(FhQuotesContext context) { this.context = context; }