示例#1
0
 /// <summary>
 /// Return the customer with the given CustomerId, or null if not found
 /// </summary>
 public Customer GetById(CustomerId id)
 {
     var db = new DbContext();
     
     // Note that this code does not trap exceptions coming from the database. What would it do with them?
     // Compare with the F# version, where errors are returned along with the Customer
     return db.Customers().Where(c => c.Id == id.Id).Select(FromDbCustomer).FirstOrDefault();
 }
示例#2
0
 /// <summary>
 /// Return all customers
 /// </summary>
 public IEnumerable<Customer> GetAll()
 {
     var db = new DbContext();
     return db.Customers().Select(FromDbCustomer);
 }