Page 1 of 1

Question to UnitOfWork Implementation

Posted: Mon 31 Jul 2017 17:33
by PixelHunter
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.

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()
To make it easy to access the repositories like

Code: Select all

this.customerBindingSource.DataSource = _unitOfWork.Customer.GetCustomerAll();
How does it is possible or meant in the generated code from the UnitOfWork template?

Please give me an example.

Re: Question to UnitOfWork Implementation

Posted: Thu 03 Aug 2017 13:15
by Shalex
Simple walkthrough with the RepositoryAndUnitOfWork template: viewtopic.php?t=24678#p85646.
Be aware about viewtopic.php?f=32&t=29479.
If this doesn't help, please specify the exact issue you have encountered (error with its stack trace, steps for reproducing, etc).