in DDD layered architecture, suppose we have UI layer that talks to Domain Model through Application Service based on ViewModel. Application Service gets generic repository through Constructor injection.
now, in UI layer for injecting generic repository, we need to add DomainModel.dll to UI project because of the type parameter of the generic repository is defined in Domain Model.
Do add DomainModel DLL to UI layer is correct or in UI layer, only AppService.dll must add to its references.
//DomainModel.dll
public class StudentEntity
{
public long ID {get;set;}
public string FirstName {get;set;}
...
}
public interface IRepository<T> where T :class
{
void Insert(T enity);
...
}
//ApplicationService.dll
public class StudentService
{
private IRepository<StudentEntity> _studentRep;
public StudentService(IRepository<StudentEntity> studentRep)
{
_studentRep=studentRep;
}
...
}
//UI layer
public class Main
{
public class Program
{
public void Main(string[] args)
{
var studentService=new StudentService(??????);
// here for injecting Generic Repository we need to add domainModel.Dll to ui for access type parameter of generic repository
}
}
}
Best Regards
Aucun commentaire:
Enregistrer un commentaire