I use repository, unit of work and dependency injection patterns in my architecture My tiers :
Core
DataLayer
BusinessLayer
ServiceLayer
There is something wrong in my structure, in unit of work class as above
public class UnitOfWork:IUnitOfWork
{
private readonly IDataContext _context;
private IKullaniciDal _kullaniciDal;
private IKategoriDal _kategoriDal;
private IUrunDal _urunDal;
public UnitOfWork(IDataContext context)
{
_context = context;
}
public IKategoriDal KategoriDal => _kategoriDal ?? (_kategoriDal = new KategoriDal(_context));
public IKullaniciDal KullaniciDal => _kullaniciDal ?? (_kullaniciDal = new KullaniciDal(_context));
public IUrunDal UrunDal => _urunDal ?? (_urunDal = new UrunDal(_context));
public void SaveChanges()
{
_context.SaveChanges();
}
}
here i want to inject DataAccessLayers like _kullaniciDAL
searched a lot and i saw some examples for generating repository genericly bu i dont want to access the repository instance directly from business, i want to access the instances of my KullaniciDal class Here is the code of KullaniciDal
public interface IKullaniciDal : IRepositoryEntityFramework<Kullanici>
{
}
public class KullaniciDal : RepositoryEntityFramework<Kullanici>, IKullaniciDal
{
public KullaniciDal(IDataContext dbContextBase) : base(dbContextBase)
{
}
}
I want to write some extra functions to data access layer in special to some of them and want to use the instances as a part of unit of work class
How can i inject Dal classes? Be carefull that i pass context object to every dal class