-
Notifications
You must be signed in to change notification settings - Fork 55
Find Object by Primary Key(s)
Long Le edited this page Sep 20, 2017
·
2 revisions
Note: The following are typically injected: IRepositoryProvider
, IDataContextAsync
, IRepository
, IRepositoryAsync
vs. manually instantiated as they are in the code samples below.
private readonly IRepositoryProvider _repositoryProvider = new RepositoryProvider(new RepositoryFactories());
using (IDataContextAsync context = new NorthwindContext())
using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context, _repositoryProvider))
{
IRepositoryAsync<Customer> customerRepository = new Repository<Customer>(context, unitOfWork);
IService<Customer> customerService = new CustomerService(customerRepository);
var customer = customerService.Find("ALFKI");
TestContext.WriteLine("Customers found: {0}", customer.ContactName);
Assert.AreEqual(customer.ContactName, "Maria Anders");
}
The Official URF Team | Docs: goo.gl/6zh9zp | Subscribe to URF Updates: @lelong37 | Blog: blog.longle.io