/// <summary> /// Using ValueTuple /// </summary> /// <param name="pCustomerIdentifier"></param> /// <returns></returns> public (string companyName, bool success) GetCustomerNameByIdentifierUsingEntityFramework_2(int pCustomerIdentifier) { Customer foundCustomer; using (var context = new SimpleEntities()) { foundCustomer = context.Customers.FirstOrDefault(customer => customer.CustomerIdentifier == pCustomerIdentifier); } return(foundCustomer != null ? (foundCustomer.CompanyName, true) : (foundCustomer.CompanyName, false)); }
public Customer GetCustomerByIdentifier(int pCustomerIdentifier) { Customer foundCustomer; using (var context = new SimpleEntities()) { foundCustomer = context.Customers .FirstOrDefault(customer => customer.CustomerIdentifier == pCustomerIdentifier); } return(foundCustomer); }
public List <Product> GetAllProducts(bool pIncludeTheKitchenSink) { using (var context = new SimpleEntities()) { return(pIncludeTheKitchenSink ? context.Products .Include(prod => prod.Category.Products.Select(product => product.Category)) .ToList() : context.Products .Include(prod => prod.Category) .ToList()); } }
public string GetCustomerNameByIdentifierUsingEntityFramework_1(int pCustomerIdentifier) { Customer foundCustomer; using (var context = new SimpleEntities()) { foundCustomer = context.Customers.FirstOrDefault(customer => customer.CustomerIdentifier == pCustomerIdentifier); } if (foundCustomer != null) { return(foundCustomer.CompanyName); } else { return(""); } }