将现有表映射到 C# 中的域类

发布于 2024-07-10 07:42:22 字数 209 浏览 5 评论 0原文

我什至不知道我是否使用了正确的术语,但这里是:

有没有一种方法可以通过工具或其他方式自动将 SQL Server 中的表及其关系映射到域(C# 代码)?

我使用了 nhibernate 插件,但它在 .cs 中创建一个文件,在 xml 中创建另一个文件,该文件具有映射,但我希望该映射在 .cs 文件中作为“属性”存在。

抱歉,如果这有点令人困惑。

I don't even know if I'm using the correct terms but here goes:

Is there a way to map the tables and their relations in a SQL Server to domain (C# code) automatically, by means of a tool or something?

I've used the nhibernate plugin, but it creates a file in .cs and another in xml, that has the mapping, but I want that mapping to be present as "property" in the .cs file.

Sorry if this is a bit confusing.

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

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

发布评论

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

评论(6

当爱已成负担 2024-07-17 07:42:22

您始终可以使用实体框架或者Linq2SQL,但我不熟悉它是如何工作的。

不过,在 EF 和 NHibernate 中,我更喜欢 NHibernate。

You could always use the Entity Framework or maybe Linq2SQL, but I'm not familiar with how that works.

Tho, out of EF and NHibernate, I prefer NHibernate.

方圜几里 2024-07-17 07:42:22

使用 Linq 2 Sql 的 LLBLgen(VS 2008 中提供)。 或者使用实体框架(在 VS 2008 SP1 中)。
Linq 2 sql 允许您将表从 sql server 拖放到画布上,并为您创建一个域类,并将属性映射到列。

Use LLBLgen of Linq 2 Sql (available in VS 2008). Or use Entity Framework (in VS 2008 SP1).
Linq 2 sql allows you to drag and drop a table from sql server to the canvas and it creates a domain class for you with properties mapped to columns.

丢了幸福的猪 2024-07-17 07:42:22

看一下 Fluent NHibernate,看看这是否是您正在寻找的:
http://blog.jagregory.com/2008/08/08 /介绍-Fluent-nhibernate/

Take a look at Fluent NHibernate and see if that is what you are looking for:
http://blog.jagregory.com/2008/08/08/introducing-fluent-nhibernate/

爱要勇敢去追 2024-07-17 07:42:22

您可以使用使用属性的Castle ActiveRecord

You can use Castle ActiveRecord which uses attributes.

如若梦似彩虹 2024-07-17 07:42:22

查看 SubSonic。 它将生成您的 DAL,还可以根据自定义模板生成代码。

Check out SubSonic. It will generate your DAL and can also generates code off of custom templates.

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