本文介绍了嵌套引用可以从dotnet core 1访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用dotnet core为我的Web项目创建了业务和数据访问层.我在业务层中添加了数据访问参考,并在UI(Web项目)层中参考了业务层.

I have created Business and DataAccess Layer for my web project using dotnet core.I have added Data access reference in Business layer and referenced the business layer in UI (web project) layer.

我看到了,我能够从我的UI(网络)项目访问我的数据访问层.我真的很想知道,这会导致违反任何应用程序设计.

I seen, I am able to access my Data access layer from my UI (web) project. I am really wondering, It can lead to violation of any application design.

如果有人遇到此问题以及如何限制从UI对数据访问层的访问,将为您提供帮助.

Appreciate help, if anybody come across this and how to restrict access to data access layer from UI.

推荐答案

是的,间接依赖项也是一种依赖项.

Yes, an indirect dependency is a dependency too.

并且您的顶级(MVC)项目必须引用所有直接或间接的内容,以便加载所有模块.并设置依赖项注入.

And your toplevel (MVC) project has to reference everything, direct or indirect, in order to get all modules loaded. And to set up the dependency injection.

通过在单独的项目中引入接口层,可以更好地分离.例如IBusinessClass和IDataAccessClass.

You can get better separation by introducing an interfaces layer in a separate project. For example IBusinessClass and IDataAccessClass.

这对除主项目以外的所有项目都适用,因此,如果您希望与示例进行这种特殊的分离,请将Controllers移至单独的项目,并仅依赖IBusiness接口.虽然我不确定MVC的约定如何工作.

That works for everything but the main project so if you want this particular separation from your example, move your Controllers to a separate project and depend that on the IBusiness interfaces only. Though I'm not sure how that works with MVC's conventions.

这篇关于嵌套引用可以从dotnet core 1访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 12:42