C# 的跨平台 ORM 是免费的,而不是 NHibernate?

发布于 2024-12-02 23:10:34 字数 799 浏览 0 评论 0原文

我有一位客户想要 ASP.NET MVC 应用程序。我将使用 VS.NET 2010 Express 来开发它,并在开发过程中在我的 Linux 服务器上向他演示(Mono 支持 ASP.NET MVC),而他最终会将其托管在运行 IIS 的商业提供商上。

快速完成这件事就是游戏的名称。我这里唯一缺少的是数据库层。理想情况下我会使用 SQL CE 和 EF4。但SQL CE只能在Windows上运行,而且Mono无论如何也不支持实体框架。

我看到的唯一免费的类似 Linq to SQL 的选项是 DbLinq。在 MySQL 数据库上进行的快速测试发现,在一个主键有两个外键的表上会出错。在谷歌上的搜索显示,大约两年前,这个错误就被识别出来,并创建了一个补丁。到目前为止,该补丁尚未应用于主要源代码,而且这个错误似乎影响了一个常见的场景,这并没有让我对 DbLinq 的生产就绪性充满信心。

即使它确实有效,也必须使用 MySQL,因为这是我期望在 Linux 和最终的 Windows 服务器上都可用的唯一数据库。 (SQLite、Berkeley DB 等都需要在服务器上安装一些本机驱动程序,我不能指望这些。)

我不知道 NHibernate。但据我了解,它需要手动创建 XML 映射文件...所以我不必编写 SQL 语句,但我必须创建映射文件? (另外,我需要学习如何使用它。)就像我上面所说的:快速完成这项工作是这里的目标。

如果必须的话,我会每月花 5 美元左右的钱购买便宜的 ASP.NET 托管提供商,并使用 SQL CE 和 EF4 用它向客户端演示进度。但在此之前,我想看看是否还有其他可行的选择。 (此时这主要是一种智力练习。)

那么......有什么建议吗?

I've got a client who wants an ASP.NET MVC application. I'll develop it with VS.NET 2010 Express, demo it to him on my Linux server during its development (Mono supports ASP.NET MVC), and he'll eventually host it on a commercial provider running IIS.

Getting this done quickly is the name of the game. The only piece I'm missing here is the database layer. Ideally I'd use SQL CE and EF4. But SQL CE only works on Windows, and Mono doesn't support the Entity Framework anyway.

The only free Linq to SQL-like option I see is DbLinq. A quick test with that on a MySQL database had it erroring out on a table that had two foreign keys to a single primary key. A search on Google shows that this bug was identified, and a patch was created, two years ago or so. That the patch still hasn't been applied to the main source by now, and that this bug seems to affect so a common scenario, does not fill me with confidence on the production-readiness of DbLinq.

Even if it did work, it'd have to be with MySQL, as that's the only database I can expect to be available on both Linux and an eventual Windows server. (SQLite, Berkeley DB, etc., would all require some native drivers be installed on the server, which I can't count on.)

I don't know NHibernate. But from what I read, it requires manually creating XML mapping files... so I don't have to write SQL statements, but I do have to create mapping files? (Plus I'd need to learn how to use it.) Like I said above: Getting this done quickly is a goal here.

If I must, I will just pony up the $5 a month or so for a cheap ASP.NET hosting provider and use that to demo progress to the client, using SQL CE and EF4. But before I do that I'd just like to see if there are any other viable options. (It's kind of mostly an intellectual exercise by this point.)

So... any tips?

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

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

发布评论

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

评论(2

ι不睡觉的鱼゛ 2024-12-09 23:10:34

它真的必须是一个完全臃肿的 ORM 吗?

我建议看一下一些所谓的“micro-orm`s”,尤其是我最喜欢的一个:Peta-Poco (http://www.toptensoftware.com/petapoco/)

Peta-Poco 在单声道和有着令人难以置信的表现。更好的是,由于代码量很小(大约 1k 行 C#),因此很容易理解幕后发生的事情,并且您可以根据需要轻松更改/扩展代码。首先,您只需复制项目中的单个 .cs 文件即可开始。

Peta-Poco 具有非常好的 poco 映射启发式方法,因此在大多数情况下,您可以通过零配置从数据库中获取 C# 对象。

Does it really have to be a fully bloated ORM?

I recommend to have a look at some of the so called "micro-orm`s", especially my favourite one: Peta-Poco (http://www.toptensoftware.com/petapoco/)

Peta-Poco runs perfectly under mono and has an incredible performance. Even better, because of the small codesize (~1k lines of c#) it is very easy to understand what`s going on under the hood and you can easily change/extend the code to your needs. For the start you just have to copy the single .cs file in your project and you are ready to go.

Peta-Poco has a very well poco-mapping heuristic so you will get your c# objects out of the db with zero configuration for the most cases.

旧城烟雨 2024-12-09 23:10:34

您可以尝试 Linq-to-SQL。从 2.6 开始在 Mono 下部分受支持,它支持 mono 下的许多数据库 发行说明 Mono 2.6 (他们正在与 DbLINQ 的人员合作来实现它)。

啊...忘了赶紧学习nhibernate怎么用了。这很好,但也很地狱。创建 XML 是最少的(并且在 NHibernate 3.2 中,他们添加了 Fluent 接口版本,因此我认为 XML 不再是必要的。您可以“编码”您的 XML。)

You COULD try Linq-to-SQL. Partially supported under Mono from 2.6, it supports many dbs under mono Release Notes Mono 2.6 (they are working with those of DbLINQ to make it).

Ah... Forget to learn quickly how to use nhibernate. It's very good but it's quite an hell. And creating the XML is the least (and with NHibernate 3.2 they have added their version of Fluent interfaces, so XML aren't anymore necessary I think. You can "code" your XML.)

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