从头开始构建数据访问层与 Visual Studio 自动生成数据访问层
我已经构建了 Windows 窗体,但有一些问题。
我想知道为什么我们必须从头开始构建数据访问层,尽管 Visual Studio 可以生成代码来做到这一点。
两者的优点/缺点是什么?
每种解决方案应该使用在什么情况下?
I've build Windows Form and I have some question.
I wonder why we have to build data access layer from scratch despite visual studio can generated code for do that.
What are the advantage/disadvantage of both ?
What is the situation that each solution should use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要向应用程序添加数据访问层 (DAL) 的开发人员可以使用多种不同的选项。我在这里假设,当您说“Visual studio 可以为此生成代码”时,您指的是 Microsoft 的实体框架 (EF),您可以使用它从架构生成业务对象和存储库(反之亦然) 。 VS 还可以通过其他方式来生成数据访问层(例如使用 T4 模板和代码生成)。在考虑是否推出自己的数据访问层时,需要考虑的一些因素包括:
如果您确实计划编写自己的 DAL,我当然建议您查看现有的代码生成选项。规划经常更改的架构,并能够快速重新生成自定义 DAL。从头开始编写 DAL 时,Code Smith、MyGeneration 和 VS 中的 T4 模板工具等工具可以提供很大帮助。
There are a number of different options available to a developer that needs to add a data access layer (DAL) to their application. I'm going to assume here that when you say "Visual studio can generate code for that", you are referring to Microsoft's Entity Framework (EF), which you can use to generate business objects and repositories from a schema (and vice versa). There are other ways that VS could be used to generate your data access layer (e.g. using T4 templates and code generation). Some of the factors that come into play when considering whether to roll your own data access layer include:
If you do plan to write your own DAL, I'd certainly recommend looking taking a look at code generation options that exist. Plan for your schema to change frequently, and be able to regenerate your custom DAL quickly. Tools like Code Smith, MyGeneration and the T4 templating tools in VS can be a great assistance when writing a DAL from scratch.