既然我已经完成了一个简单的数据库,那么构建极轻量级业务对象/DAL 的首选方法是什么?

发布于 2024-08-28 00:45:05 字数 563 浏览 4 评论 0原文

我已经为一个项目完成了一个简单的数据库。只有6张桌子。在这 6 个表中,有一个是“查找”表。

有一个“主”表是系统的驱动程序。它被其他四个表作为外键引用。

至此步骤完成。创建可以加载数据和子数据的 POCO/BizObjects 的最快、最简单的方法是什么。

这是我的警告。

  • 我不想花超过 30-60 分钟来学习如何?
  • POCO 中几乎不需要任何业务逻辑。他们几乎会加载数据。甚至不需要写回数据。
  • 我已经了解 CSLA(最高版本 3),但我觉得这对于这个小项目来说有点过分了。
  • 尽管如此,如果 ROOT 对象可以拥有包含 CSLA 中的 CHILD 对象的集合类,我会很高兴……但同样,不使用 CSLA。
  • 请给出 .NET 35 的答案,但如果我被限制只能使用 .NET 20,也请给出答案。
  • 理想情况下,我可以只在数据库中指向一个工具,然后 POCO 就会生成。
  • 免费

只是好奇你们在这种情况下使用什么。

我知道这个问题是主观的,但我想听到各种各样的答案。

赛斯

I have completed a simple database for a project. Only 6tables. Of the 6, one is a "lookup" table.

There is one "master" table that is the driver for the system. It is referenced as a foreign key by the other four tables.

Give that this step is completed. What is the FASTEST, EASIEST way to create POCOs/BizObjects that can load load the data and the child data.

Here are my CAVEATS.

  • I don't want to spend more than 30-60 minutes learning how?
  • There is very little biz logic needed in the POCOs. They will pretty much load data. Don't even really need to write back data.
  • I already know CSLA (up to version 3) but I feel that is overkill for this little project.
  • Nevertheless, I would love it if it ROOT objects could have collection classes that contain the CHILD objects as in CSLA...but again, without using CSLA.
  • Please give the answer for .NET 35 but also if I was restricted to only use .NET 20.
  • Ideally I could just point a tool at the database and the POCOs would be genn'ed.
  • FREE

Just curious what you guys use for this kind of scenario.

I understand that this question is subjective but I want to hear a variety of answers.

Seth

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

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

发布评论

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

评论(3

寄与心 2024-09-04 00:45:05

我的选择是使用 sqlmetal 的 linq-to-sql 从数据库生成代码。

Sqlmetal 是一个命令行工具,无需定制即可为数据库生成类。与 linq-to-sql 设计器相比的优点是,如果对数据库有任何更改,您可以轻松地重新运行该工具来重新生成类。使用设计器始终存在代码未更新以匹配数据库的风险。

My choice would be linq-to-sql using sqlmetal to generate the code from the database.

Sqlmetal is a command line tool that generates classes for the database without customization. The advantage compared to the linq-to-sql designer is that you can easily rerun the tool to regenerate the classes if you have any changes to the database. Using the designer there is always a risk that the code isn't updated to match the database.

黎歌 2024-09-04 00:45:05

使用 ORM,例如 nHibernateSubSonicLinq to SQL< /a> 或实体框架

它们都会为您生成类和数据层。

启动和运行最快的是 Linq to SQL,因为它内置于 VS 2008 中(指向 SQL 服务器,拖放,神奇!)。链接文本

Use an ORM like nHibernate, SubSonic, Linq to SQL or Entity Framework.

They will all generate classes for you and a data layer.

The fastest to get up and running would be Linq to SQL, as it is built into VS 2008 (point to a SQL server, drag and drop, magic!).link text

节枝 2024-09-04 00:45:05

对于 .NET 3.5,LINQ 到 SQL;将表拖到数据上下文中,工作就完成了。实际上任何 ORM 都可以,但 LINQ-to-SQL 是一种仅使用 MS 工具和 VS IDE 即可完成工作的快速方法。

它们不是以这种方式完成的“纯粹” POCO(它们具有 L2S 属性等),但它很简单。您可以使用 L2S 进行纯粹的 POCO,但这需要更多的努力。

2.0 版本中,NHibernate。但更多的工作是,除非您使用额外的工具,否则您必须编写类和/或映射文件。

For .NET 3.5, LINQ-to-SQL; drag the tables onto a data-context, job done. Actually any ORM would probably do, but LINQ-to-SQL is a very quick way of getting the job done using just the MS tools and VS IDE.

They aren't "pure" POCO done this way (they have L2S attributes etc), but it is easy. You can do pure POCO with L2S, but it takes a bit more effort.

With 2.0, NHibernate. But more work as unless you use additional tooling you'll have to write the classes and/or mapping files.

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