Skip to content

Instantly share code, notes, and snippets.

@TWolverson
Created March 6, 2019 13:56
Show Gist options
  • Save TWolverson/e33757de74472c1c007b3653c9a8b1c8 to your computer and use it in GitHub Desktop.
Save TWolverson/e33757de74472c1c007b3653c9a8b1c8 to your computer and use it in GitHub Desktop.
public class CustomersController
{
private readonly IQueryable<Customer> customersQuery;
public CustomersController(IQueryable<Customer> customersQuery)
{
this.customersQuery = customersQuery;
}
public Customer Get(int id)
{
try
{
return customerQuery.Single(customer => customer.Id = id);
}
catch(InvalidOperationException e)
{
return NotFound();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment