public Customer DeleteCustomer(Customer customer) { var customerToDelete = _context.Customers.FirstOrDefault(c => c.Id == customer.Id); if (customerToDelete != null) { _context.Customers.Remove(customerToDelete); _context.SaveChanges(); } return(customerToDelete); }
public QueryTestFixture() { var options = new DbContextOptionsBuilder <AlintaContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; Context = new AlintaContext(options); Context.Database.EnsureCreated(); Context.Customers.AddRange(new[] { new Customer("Adam", "Levine", new DateTime(1990, 1, 1)), new Customer("Sean", "Bean", new DateTime(1970, 11, 11)), new Customer("Adam", "Lambert", new DateTime(1980, 5, 5)), }); Context.SaveChanges(); }