是列表<>比 ASP.Net 中 UI 层的 DataSet 更好? [英] Is List<> better than DataSet for UI Layer in ASP.Net?

查看:15
本文介绍了是列表<>比 ASP.Net 中 UI 层的 DataSet 更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据从我的数据访问层获取到我的业务层,然后准备在我的 UI 中使用.

所以我想知道:通过 DataReader 读取我的数据并使用它来填充 List<BLClasses> 或填充 是否更好DataSet 并将 DataSet 发送到 UI 层 ??.

我对良好的性能和可扩展性感兴趣.

解决方案

你的 UI 层应该远离你的数据访问策略——它不应该处理原始数据.因此,您的 UI 应该只与您的域对象通信(直接或通过服务层).

然后,您可以让 UI 层创建渲染所需的数据结构.任何性能问题都可以通过缓存策略来缓解.

这会影响代码的可读性、可测试性和可维护性,而这始终是任何设计的长期和短期目标.

我认为理想情况下,您希望看到以下方面的内容:

<上一页>用户界面/||服务(?取决于设计)/||领域/||DCO/||达尔

另一方面,如果您正在构建一个非常简单的 WebForms 应用程序,那么您可以放弃其中的一些复杂性,而只需使用 Visual Studio 提供的设计器.然而,我发现应用程序的发展往往超出了拖放界面的功能,您最终不得不重构为更加独立的设计.

您始终需要了解通过选择架构策略会获得/失去什么.如果您可以在没有测试、可读性降低和 UI 与数据更紧密耦合的情况下(处于边缘)生活****颤抖****,那么也许更直接的方法适合您.

一些进一步阅读的链接

I want to get data from my data access layer into my business layer, then prepare it for use in my UI.

So i wonder: is it better to read my data by DataReader and use it to fill a List<BLClasses> or to fill a DataSet and send the DataSet to UI Layer ??.

I'm interested in good performance and scalability.

解决方案

Your UI layer should be far-removed from your data access strategy - it shouldn't be dealing with raw data. Thus, your UI should communicate solely with your domain objects (directly or through a service layer).

You can then have the UI layer create the data structures that it needs in order to render. Any performance concerns could be mitigated through a caching strategy.

This affects the readability, testability and maintainability of the code which should always be long- and short-term goals of any design.

I think ideally you'd want to see something along these lines:

 UI
 /|
  |
SERVICE (? depending on the design)
 /|
  |
DOMAIN
 /|
  |
 DCO
 /|
  |
 DAL

EDIT:

On the flip-side, if you're building a very straight-forward WebForms application, then you may be able to forgo some of this complexity and just use the designers provided by Visual Studio. I've found, however, that applications often evolve beyond the capabilities of the drag-and-drop interface and you end up having to refactor into a more separated design.

You always need to know what you stand to gain/lose by choosing an architectural strategy. If you can live (on the edge) with no testing, reduced readability and tighter coupling of the UI to the data ****shudder****, then perhaps the more straight-forward approach is for you.

Some links for further reading

这篇关于是列表&lt;&gt;比 ASP.Net 中 UI 层的 DataSet 更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆