-3
我有一个3层应用程序,图层为:
Web:表示层(ASP.NET MVC) - >仅希望看到服务层 BLL:服务层 - >仅看到DAL DAL:数据访问层 - >握住我的EDMX
IAM使用下面的工作单位和存储库:从web项目中删除dal引用
public interface IUnitOfWo
{
IGenericRepo<Actor,ActorDto> ActorRepo{ get; }
void Save();
}
这里是实现IUnitOfWork的
public IGenericRepo<Actor, ActorDto> ActorRepo
{
get { return actorRepo ??(actorRepo = new GenericRepo<NtierMvcAppEntities, Actor, ActorDto>()); }
}
和Web应用程序,我想不使用DAL获取这样的数据:
private IUnitOfWo _unitOfWork;
public TestController(IUnitOfWo unitOfWork)
{
_unitOfWork = unitOfWork;
}
public ActionResult Index()
{
// get all models
List<ActorDto> modelList = _unitOfWork.ActorRepo.GetAll();
// this line wont work without have reference of DAL.dll
return View(modelList);
}
有人说_infinite monkeys_?我认为他们刚刚在哈姆雷特工作 – MickyD
:你可以要求更多的信息! – samir448