ASP.Net分层通信

发布于 2024-09-01 10:20:34 字数 468 浏览 2 评论 0原文

我们正在开发一个分层的 Web 应用程序。规格:

  • 3层,数据层,业务层, 用户界面层。
  • 用 C# 编程
  • 数据层使用实体框架

目前我们计划让数据层通过 linq 2 实体将 IEnumerable返回到业务层,业务层将数据返回到 ui 层。

由于 ui 层不知道数据层的存在,它如何处理从 BLL 传递给它的 IEnumerable 结果,其中 T 在数据层中定义?

有没有关于如何做到这一点的好例子。请注意,我对松散耦合层的工厂/接口/抽象非常陌生。

我在这里看到了问题在 ntier 应用程序中传递数据,建议让实体层在所有层之间共享...但是我不希望其他层能够查询数据库。

We're developing a layered web application. The specs:

  • 3 layers, data layer, business layer,
    ui layer.
  • Programmed in C#
  • Data Layer uses the entity framework

Currently we plan on having the data layer return IEnumerable<T> to the business layer via linq 2 entities, and the business layer will return data to the ui layer.

Since the ui layer has no knowledge of the existance of the data layer, how would it handle a result of IEnumerable passed to it from the BLL, where T is defined in the data layer?

Are there any GOOD example out there on how to do this. Please note that I'm extremely new to factories / interfaces / abstraction to loosely couple layers.

I saw the question here passing data in an ntier application and it was recommended to have the entity layer shared amongst all layers... however I do not want the other layers to be able to query the database.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半透明的墙 2024-09-08 10:20:34

将数据对象定义在单独的项目中,或者至少是单独的命名空间中,以便显示层可以引用对象,但不能引用有权访问数据库的 DAL。

Have your data objects defined in a separate project, or at least a separate namespace, so the Display layer can have a reference to the objects, but not the DAL that has access to the db.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文