public Customer GetCustomerById(string id) { System.Console.WriteLine("Received GetCustomerById() request."); var db = new NorthwindEntities(); return db.Customers.Where(c => c.CustomerID == id).FirstOrDefault(); }
public IEnumerable<Customer> GetCustomers() { System.Console.WriteLine("Received GetCustomers() request."); var db = new NorthwindEntities(); return db.Customers.Take(10).ToList(); }
private static void checkDatabase() { try { var db = new NorthwindEntities(); var read = db.Customers.Where(c => c.CustomerID == "!").FirstOrDefault(); var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Connected to Database"); Console.ForegroundColor = color; } catch (Exception exp) { var color = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(exp.Message); Console.ForegroundColor = color; } }