Question to UnitOfWork Implementation
Posted: Mon 31 Jul 2017 17:33
After many hours of training and analysis I get an better idea how your tool and the generated code works.
I really miss some working sample projects and source code, this would make things easier for me.
Here is my question:
I learned that the UnitOfWork implementation should contain the repositories of each entities.
To make it easy to access the repositories like
How does it is possible or meant in the generated code from the UnitOfWork template?
Please give me an example.
I really miss some working sample projects and source code, this would make things easier for me.
Here is my question:
I learned that the UnitOfWork implementation should contain the repositories of each entities.
Code: Select all
public class UnitOfWork : IUnitOfWork
{
private readonly Context _context;
public ICustomerRepository Customer { get; private set; }
public ISalesRepository Sales { get; private set; }
public UnitOfWork(Context context)
{
_context = context;
Customer = new CustomerRepository(_context);
Sales = new SalesRepository(_context);
}
public int Complete()
{
return _context.SaveChanges();
}
public void Dispose()
{
_context.Dispose();
}
}
Code: Select all
this.customerBindingSource.DataSource = _unitOfWork.Customer.GetCustomerAll();
Please give me an example.