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

时间:2021-08-27 12:21:32

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.

我有一个想要ASP.NET MVC应用程序的客户端。我将使用VS.NET 2010 Express开发它,在开发期间在我的Linux服务器上演示它(Mono支持ASP.NET MVC),并且他最终将它托管在运行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.

快速完成这项工作就是游戏的名称。我在这里唯一缺少的是数据库层。理想情况下我会使用SQL CE和EF4。但SQL CE仅适用于Windows,而Mono无论如何都不支持实体框架。

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.

我看到的唯一免费的Linq to SQL-like选项是DbLinq。在MySQL数据库上进行的快速测试使得它在一个具有两个外键到一个主键的表上出错。在Google上进行的搜索显示,这个错误已经确定,并且两年前左右创建了补丁。补丁现在还没有应用到主要来源,并且这个bug似乎影响了这么常见的场景,并没有让我对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.)

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

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.

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

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.)

如果必须的话,我会花一个月大约5美元购买一个廉价的ASP.NET托管服务提供商,并使用它来使用SQL CE和EF4向客户端演示进度。但在我这样做之前,我只想看看是否有其他可行的选择。 (到目前为止,这主要是一种智力锻炼。)

So... any tips?

所以...任何提示?

2 个解决方案

#1


1  

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).

您可以尝试使用Linq-to-SQL。在单声道支持2.6下,它支持单声道发行说明Mono 2.6下的许多dbs(它们与DbLINQ的那些一起使用)。

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.)

啊...忘了快速学习如何使用nhibernate。这是非常好的,但这是一个地狱。并且创建XML是最少的(并且使用NHibernate 3.2他们已经添加了他们的Fluent接口版本,因此我认为不再需要XML。您可以“编写”XML。)

#2


2  

Does it really have to be a fully bloated ORM?

它真的必须是一个完全膨胀的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/)

我建议看看一些所谓的“micro-orm`s”,特别是我最喜欢的一个: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在单声道下完美运行并具有令人难以置信的性能。更好的是,由于代码量小(大约1k行的c#),很容易理解底层的内容,您可以轻松地根据需要更改/扩展代码。首先,您只需复制项目中的单个.cs文件即可开始使用。

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.

Peta-Poco有一个非常好的poco映射启发式,因此在大多数情况下,您将从数据库中获取c#对象,零配置。

#1


1  

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).

您可以尝试使用Linq-to-SQL。在单声道支持2.6下,它支持单声道发行说明Mono 2.6下的许多dbs(它们与DbLINQ的那些一起使用)。

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.)

啊...忘了快速学习如何使用nhibernate。这是非常好的,但这是一个地狱。并且创建XML是最少的(并且使用NHibernate 3.2他们已经添加了他们的Fluent接口版本,因此我认为不再需要XML。您可以“编写”XML。)

#2


2  

Does it really have to be a fully bloated ORM?

它真的必须是一个完全膨胀的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/)

我建议看看一些所谓的“micro-orm`s”,特别是我最喜欢的一个: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在单声道下完美运行并具有令人难以置信的性能。更好的是,由于代码量小(大约1k行的c#),很容易理解底层的内容,您可以轻松地根据需要更改/扩展代码。首先,您只需复制项目中的单个.cs文件即可开始使用。

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.

Peta-Poco有一个非常好的poco映射启发式,因此在大多数情况下,您将从数据库中获取c#对象,零配置。