有关.NET ORM学习的一些建议

时间:2021-12-19 12:47:34

I am a little ashamed to say that I have never used an ORM; as you may recall most of my career experience is hacking around with Classic ASP and the little .NET I do tends to be maintenance only.

我有点惭愧地说我从未使用过ORM;你可能还记得我的大部分职业经历都是使用经典ASP和小.NET进行攻击,而我只做维护。

For my own career as well as in preparation for a new project at work (done in .NET finally!) I'm looking at adding an ORM to my skillset - being the masochist I am I'm also going to look at TDD while I'm at it for this project.

为了我自己的职业生涯以及为工作中的新项目做准备(最终在.NET中完成!)我正在考虑在我的技能组中添加一个ORM - 作为受虐狂我是我也将看TDD而我正忙于这个项目。

Anyways, I am using .NET 3.5 for the project (or plan to, anyways) so I am trying to decide what ORM I want to choose; like I said I am not really familiar with them but I know generally what they are supposed to do and how they do it. My choices are basically down to NHibernate or LINQ/Entity Framework. I haven't used any, but I've seen some demos of LINQ2SQL and of NHibernate.

无论如何,我使用.NET 3.5进行项目(或计划,反正)所以我试图决定我想选择什么ORM;就像我说我对它们并不熟悉但我一般都知道它们应该做什么以及它们是如何做到的。我的选择基本上归结为NHibernate或LINQ / Entity Framework。我没有使用过任何东西,但我看过一些LINQ2SQL和NHibernate的演示。

NHibernate seems like it's more robust overall (Linq2Sql isn't even a "true" ORM) as well as heavily used in the ALT.NET community, which I want to explore more. However, EF is Microsoft's offering and, as such, will be heavily used by the majority of development teams out there who just use whatever Microsoft comes out with and don't look at any alternatives.

NHibernate看起来总体上更健壮(Linq2Sql甚至不是“真正的”ORM)以及在ALT.NET社区中大量使用,我想要探索更多。但是,EF是微软的产品,因此,大多数开发团队都会大量使用EF,他们只使用微软推出的任何产品,而不会考虑任何其他选择。

I've heard both good and bad things about EF, but I want to pick something that will give me a good foundation as well as look good to other employers if/when I find a better job in a company with a real development team.

我已经听说了关于EF的好事和坏事,但是如果/当我在一个拥有真正开发团队的公司找到一份更好的工作时,我想选择能给我一个良好基础的东西以及对其他雇主好看的东西。

EDIT: I should add that, if it matters any in picking an ORM, the application will have to deal with an existing database.

编辑:我应该补充一点,如果在选择ORM时有任何问题,应用程序将不得不处理现有的数据库。

EDIT (02/15/2009 6:48 PM): The only database it will use is SQL Server 2005 Standard, running on Windows Server 2003. Given that this is for a project for work, my goal is to pick something that won't take me a very long time to get up to speed with (as I'm going to need to be productive and "Learning a new tool" won't look good to managemetn) but something that will be better than rolling my own DAL. At the time I haven't decided if the application will be a smart client or an ASP.NET application, but one part of it is more than likely going to be done with ASP.NET MVC.

编辑(02/15/2009 6:48 PM):它将使用的唯一数据库是SQL Server 2005 Standard,在Windows Server 2003上运行。鉴于这是一个工作项目,我的目标是选择一些赢得的东西我需要很长时间才能加快速度(因为我需要提高工作效率,“学习新工具”对管理来说看起来不太好)但是这比滚动我自己的DAL要好一些。当时我还没有确定应用程序是智能客户端还是ASP.NET应用程序,但其中的一部分很可能是用ASP.NET MVC完成的。

9 个解决方案

#1


I would recommend nhibernate - since it is open source and has a very active community help is easy to get. A great starting point is The NHibernate FAQ, it ranges from post for beginners to very advanced concepts. Hit the ground running by reading and following Prepare your system for NHibernate and Your first NHibernate based application.

我推荐nhibernate - 因为它是开源的,并且有一个非常活跃的社区帮助很容易获得。一个很好的起点是NHibernate常见问题解答,它包括从初学者的帖子到非常先进的概念。通过阅读和遵循准备您的NHibernate系统和您的第一个基于NHibernate的应用程序来实现目标。

All employers that I worked for used NHibernate for ORM in .NET and Hibernate for ORM in Java - so you should benefit greatly from learning NHibernate.

我工作的所有雇主都使用NHibernate for .NET中的ORM和Hibernate for Java中的ORM - 所以你应该从学习NHibernate中受益匪浅。

#2


SubSonic from Rob Connery is a "Swiss Army knife" ORM based on ActiveRecord. You can be productive with it in 30 minutes. Be warned, it is NOT at the level of NHibernate in terms configuration options, etc. It is hugely productive, and the code is very clean. We use it on most of our projects.

Rob Connery的SubSonic是一款基于ActiveRecord的“瑞士军刀”ORM。您可以在30分钟内使用它。请注意,它不是NHibernate级别的配置选项等。它非常高效,而且代码非常干净。我们在大多数项目中使用它。

#3


Many discussions on this topic on Stack Overflow:

Stack Overflow上有关于此主题的许多讨论:

What object mapper solution would you recommend for .net?

你会为.net推荐什么对象映射器解决方案?

What is the best data access paradigm for scalability?

什么是可扩展性的最佳数据访问范例?

Persistence framework?

Both EF and Nhibernate are considered useful for large projects. Some of the main concerns expressed about EF are lack of lazy loading/persistence ignorance. Nhibernate has a steeper learning curve and requires more manual configuration.

EF和Nhibernate都被认为对大型项目有用。关于EF的一些主要担忧是缺乏延迟加载/持久性无知。 Nhibernate具有更陡峭的学习曲线,需要更多的手动配置。

#4


Why limit yourself to just one while learning? Why not dabble with all of them and see which ones feel best to you? Then you can begin a deep dive in those technologies and get more out of them.

为什么在学习的同时限制自己只有一个?为什么不跟他们一起玩,看看哪个最适合你呢?然后,您可以开始深入研究这些技术并从中获得更多。

Personally, I would start out with LINQ to SQL because it's so drop-dead easy. Play around with it just to get used to the idea of how an ORM can be used. You'll be surprised at how simple it is and how easy it is to get started, and then you'll probably come across many of the pain points which lead some people on to Entity Framework.

就个人而言,我会从LINQ to SQL开始,因为它太简单了。玩它只是为了习惯如何使用ORM。你会惊讶于它的简单性和开始是多么容易,然后你可能会遇到很多让一些人进入Entity Framework的痛点。

Once you use Entity Framework a little bit, you'll either be satisfied with it or you'll wonder what the big deal is with nHibernate and some of the others mentioned in related questions.

一旦你稍微使用了Entity Framework,你就会对它感到满意,或者你会想知道nHibernate与相关问题中提到的其他一些内容有什么关系。

It's at that point, in my opinion, that you'll be most primed to be successful with something like nHibernate, which may be a tough to learn as a first foray into ORM-land.

在我看来,正是在这一点上,你将最有可能在nHibernate这样的东西上获得成功,这可能是第一次进入ORM-land时难以学习的东西。

Either way, I don't prescribe to the "which one should I try" school of thought. Try them all, I say.

无论哪种方式,我都没有规定“我应该尝试哪一个”思想学派。我说,试试这些。

#5


I would say go with NHibernate. It is widely used, has a number of tutorials and learning resources and an active contrib group. It is similar to Hibernate which means any skills you learn on the .NET NHibernate are portable to Java. Win-win-win-etc. :)

我会说NHibernate。它被广泛使用,有许多教程和学习资源以及一个活跃的贡献组。它与Hibernate类似,这意味着您在.NET NHibernate上学到的任何技能都可以移植到Java。互利双赢等。 :)

#6


I second David Robbins's mention of subsonic. One downfall that I will point out though is that the documentation is less than perfect. It's really pretty simple to work with, you just have to know how to do it.

我第二次大卫罗宾斯提到亚音速。我要指出的一个缺点是文档不完美。使用它真的很简单,你只需知道如何做到这一点。

I suppose one other thing that's worth mentioning: what databases do you need to support? If you need to work with anything other than SQL Server, I wouldn't use LINQ. I could be wrong on this, but last time I checked, there isn't any good support for databases other than SQL Server.

我想还有一件值得一提的事:你需要支持哪些数据库?如果你需要使用SQL Server以外的任何东西,我不会使用LINQ。我可能错了,但上次检查时,除了SQL Server之外,对数据库没有任何好的支持。

The last thing that I would mention is that you don't have to choose just one. I've used nHibernate, LINQ to SQL, and Subsonic in the same project with decent success (although I'd advise to avoid that if at all possible). My advice is to spend a little bit of time with all of them and learn what's best about each one.

我要提到的最后一件事是你不必只选择一个。我在同一个项目中使用了nHibernate,LINQ to SQL和Subsonic并取得了不错的成功(尽管我建议尽可能避免这种情况)。我的建议是花一点时间与所有人一起学习每个人的最佳状态。

Here's what I would say about each one:

以下是我对每个人的看法:

  • LINQ to SQL - very easy to get up and running with. But if you want to use something other than SQL Server, you're pretty much SOL.
  • LINQ to SQL - 非常容易启动和运行。但是如果你想使用SQL Server之外的其他东西,你就是SOL。

  • NHibernate - This is probably the most powerful out of all the ORMs and it supports the most RDBMSes, but it can be tedious to work with as there aren't a lot of really good free code generators to work with (can't speak for the non-free ones though).
  • NHibernate - 这可能是所有ORM中最强大的,它支持大多数RDBMS,但它可能很繁琐,因为没有很多真正好的免费代码生成器可以使用(不能代表虽然非*的)。

  • SubSonic - A good compromise between NHibernate and LINQ to SQL. It doesn't support as many RDBMSes as NHibernate, but it works with most of the ones you'd encounter in the business world.
  • SubSonic - NHibernate和LINQ to SQL之间的良好折衷。它不支持与NHibernate一样多的RDBMS,但它适用于您在商业世界中遇到的大多数RDBMS。

TL;DR: NHibernate if you need to have a lot of control over the database or need to support something obscure. SubSonic if you need to work with something other than SQL Server. LINQ to SQL if you just want to run against SQL Server.

TL; DR:NHibernate如果您需要对数据库进行大量控制或需要支持一些模糊的东西。 SubSonic如果您需要使用SQL Server以外的其他东西。 LINQ to SQL如果你只想对SQL Server运行。

#7


Since you are using .NET 3.5, I recommend LINQ.
LINQ reuires only that IEnumerable and IQueryable interfaces are implemented.
That means it is not limited to relational data.
Alse see the article ORM in .NET 3.5

由于您使用的是.NET 3.5,我推荐使用LINQ。 LINQ仅要求实现IEnumerable和IQueryable接口。这意味着它不仅限于关系数据。另请参阅.NET 3.5中的ORM文章

#8


For the free and open source route, NHibernate is pretty hard to beat. It's a mature ORM with a very active community and plenty of support. There is an initial learning curve there with NHibernate, however, I think it's well worth the effort you might invest in it.

对于免费和开源的路线,NHibernate很难被击败。这是一个成熟的ORM,拥有非常活跃的社区和充足的支持。 NHibernate有一个初步的学习曲线,但是,我认为你可能投入的努力是值得的。

If you want to stay within Micrsoft's .NET world, LINQ is a great technology to learn, and not just LINQ2SQL (which as you say, isn't a full-blown ORM anyway) as LINQ can be applied to objects, XML and basically anything that's IEnumerable/IQueryable.

如果你想留在Micrsoft的.NET世界中,LINQ是一个很好的学习技术,而不仅仅是LINQ2SQL(正如你所说,它不是一个完整的ORM),因为LINQ可以应用于对象,XML和基本任何IEnumerable / IQueryable。

For the future, I'd recommend Entity Framework (again, within the Microsoft world). There has been a few scary sounding announcements from the LINQ2SQL team within Microsoft which seem to suggest that all future development effort will be put into Entity Framework rather than LINQ2SQL. There is a certain amount of overlap of those technologies anyway. Certainly, I don't believe that LINQ (speaking generally) is going away any time soon, but I'd be careful of investing for the long term in LINQ2SQL. Entity Framework is still relatively new, and under active development, so expect to see EF mature in the coming months/years.

对于未来,我建议实体框架(再次,在微软世界内)。微软内部的LINQ2SQL团队发布了一些可怕的声音,似乎表明所有未来的开发工作都将放入实体框架而不是LINQ2SQL。无论如何,这些技术存在一定程度的重叠。当然,我不相信LINQ(一般来说)很快就会消失,但我会小心在LINQ2SQL中进行长期投资。实体框架仍然相对较新,并且在积极开发中,因此期望EF在未来几个月/几年内成熟。

So, right at this moment, LINQ2SQL is great and you can get up and running with it quite quickly without necessarily having to dive into the inner workings of it (i.e. expression trees etc.) but for the future, I'd recommend Entity Framework/NHibernate as I believe these two ORM's will be the ones in majority use over the next few years by most .NET dev teams.

所以,就在这时,LINQ2SQL很棒,你可以很快地启动和运行它,而不必深入研究它的内部工作(即表达式树等),但对于未来,我建议实体框架/ NHibernate我相信这两个ORM将成为大多数.NET开发团队在未来几年内大多数使用的ORM。

Of course, that said, there are a myriad of different ORM solutions out there, and I doubt any one of them will be a one-size-fits-all solution, so you really have to examine each of them and see which is most suitable for the specific project that you're working on.

当然,那里说有很多不同的ORM解决方案,我怀疑它们中的任何一个都是一个通用的解决方案,所以你真的必须检查每个解决方案,看看哪个是最适合您正在进行的特定项目。

#9


Checkout XmlDataMapper a simple free ORM (LGPL Licence) which leaves a low memory footprint compared to the other giants.
The sample project provided should be good enough to get started.

结帐XmlDataMapper是一个简单的免费ORM(LGPL许可证),与其他巨头相比,它的内存占用量较低。提供的示例项目应该足够好以便开始。

To integrate XmlDataMapper all you need to do is 4 little steps

要集成XmlDataMapper,您需要做的只有4个小步骤

  1. Create a Business Entity / DTO for the tables
  2. 为表创建业务实体/ DTO

  3. Create an XML File with the mapping information between the table and the DTO.
  4. 使用表和DTO之间的映射信息创建XML文件。

  5. Specify the DTO and xml file in the configuration.
  6. 在配置中指定DTO和xml文件。

  7. Just call the DTOConverter.Convert(dataReader) and other such methods to convert your database record to DTO / Business Entity
  8. 只需调用DTOConverter.Convert(dataReader)和其他此类方法将您的数据库记录转换为DTO / Business Entity

#1


I would recommend nhibernate - since it is open source and has a very active community help is easy to get. A great starting point is The NHibernate FAQ, it ranges from post for beginners to very advanced concepts. Hit the ground running by reading and following Prepare your system for NHibernate and Your first NHibernate based application.

我推荐nhibernate - 因为它是开源的,并且有一个非常活跃的社区帮助很容易获得。一个很好的起点是NHibernate常见问题解答,它包括从初学者的帖子到非常先进的概念。通过阅读和遵循准备您的NHibernate系统和您的第一个基于NHibernate的应用程序来实现目标。

All employers that I worked for used NHibernate for ORM in .NET and Hibernate for ORM in Java - so you should benefit greatly from learning NHibernate.

我工作的所有雇主都使用NHibernate for .NET中的ORM和Hibernate for Java中的ORM - 所以你应该从学习NHibernate中受益匪浅。

#2


SubSonic from Rob Connery is a "Swiss Army knife" ORM based on ActiveRecord. You can be productive with it in 30 minutes. Be warned, it is NOT at the level of NHibernate in terms configuration options, etc. It is hugely productive, and the code is very clean. We use it on most of our projects.

Rob Connery的SubSonic是一款基于ActiveRecord的“瑞士军刀”ORM。您可以在30分钟内使用它。请注意,它不是NHibernate级别的配置选项等。它非常高效,而且代码非常干净。我们在大多数项目中使用它。

#3


Many discussions on this topic on Stack Overflow:

Stack Overflow上有关于此主题的许多讨论:

What object mapper solution would you recommend for .net?

你会为.net推荐什么对象映射器解决方案?

What is the best data access paradigm for scalability?

什么是可扩展性的最佳数据访问范例?

Persistence framework?

Both EF and Nhibernate are considered useful for large projects. Some of the main concerns expressed about EF are lack of lazy loading/persistence ignorance. Nhibernate has a steeper learning curve and requires more manual configuration.

EF和Nhibernate都被认为对大型项目有用。关于EF的一些主要担忧是缺乏延迟加载/持久性无知。 Nhibernate具有更陡峭的学习曲线,需要更多的手动配置。

#4


Why limit yourself to just one while learning? Why not dabble with all of them and see which ones feel best to you? Then you can begin a deep dive in those technologies and get more out of them.

为什么在学习的同时限制自己只有一个?为什么不跟他们一起玩,看看哪个最适合你呢?然后,您可以开始深入研究这些技术并从中获得更多。

Personally, I would start out with LINQ to SQL because it's so drop-dead easy. Play around with it just to get used to the idea of how an ORM can be used. You'll be surprised at how simple it is and how easy it is to get started, and then you'll probably come across many of the pain points which lead some people on to Entity Framework.

就个人而言,我会从LINQ to SQL开始,因为它太简单了。玩它只是为了习惯如何使用ORM。你会惊讶于它的简单性和开始是多么容易,然后你可能会遇到很多让一些人进入Entity Framework的痛点。

Once you use Entity Framework a little bit, you'll either be satisfied with it or you'll wonder what the big deal is with nHibernate and some of the others mentioned in related questions.

一旦你稍微使用了Entity Framework,你就会对它感到满意,或者你会想知道nHibernate与相关问题中提到的其他一些内容有什么关系。

It's at that point, in my opinion, that you'll be most primed to be successful with something like nHibernate, which may be a tough to learn as a first foray into ORM-land.

在我看来,正是在这一点上,你将最有可能在nHibernate这样的东西上获得成功,这可能是第一次进入ORM-land时难以学习的东西。

Either way, I don't prescribe to the "which one should I try" school of thought. Try them all, I say.

无论哪种方式,我都没有规定“我应该尝试哪一个”思想学派。我说,试试这些。

#5


I would say go with NHibernate. It is widely used, has a number of tutorials and learning resources and an active contrib group. It is similar to Hibernate which means any skills you learn on the .NET NHibernate are portable to Java. Win-win-win-etc. :)

我会说NHibernate。它被广泛使用,有许多教程和学习资源以及一个活跃的贡献组。它与Hibernate类似,这意味着您在.NET NHibernate上学到的任何技能都可以移植到Java。互利双赢等。 :)

#6


I second David Robbins's mention of subsonic. One downfall that I will point out though is that the documentation is less than perfect. It's really pretty simple to work with, you just have to know how to do it.

我第二次大卫罗宾斯提到亚音速。我要指出的一个缺点是文档不完美。使用它真的很简单,你只需知道如何做到这一点。

I suppose one other thing that's worth mentioning: what databases do you need to support? If you need to work with anything other than SQL Server, I wouldn't use LINQ. I could be wrong on this, but last time I checked, there isn't any good support for databases other than SQL Server.

我想还有一件值得一提的事:你需要支持哪些数据库?如果你需要使用SQL Server以外的任何东西,我不会使用LINQ。我可能错了,但上次检查时,除了SQL Server之外,对数据库没有任何好的支持。

The last thing that I would mention is that you don't have to choose just one. I've used nHibernate, LINQ to SQL, and Subsonic in the same project with decent success (although I'd advise to avoid that if at all possible). My advice is to spend a little bit of time with all of them and learn what's best about each one.

我要提到的最后一件事是你不必只选择一个。我在同一个项目中使用了nHibernate,LINQ to SQL和Subsonic并取得了不错的成功(尽管我建议尽可能避免这种情况)。我的建议是花一点时间与所有人一起学习每个人的最佳状态。

Here's what I would say about each one:

以下是我对每个人的看法:

  • LINQ to SQL - very easy to get up and running with. But if you want to use something other than SQL Server, you're pretty much SOL.
  • LINQ to SQL - 非常容易启动和运行。但是如果你想使用SQL Server之外的其他东西,你就是SOL。

  • NHibernate - This is probably the most powerful out of all the ORMs and it supports the most RDBMSes, but it can be tedious to work with as there aren't a lot of really good free code generators to work with (can't speak for the non-free ones though).
  • NHibernate - 这可能是所有ORM中最强大的,它支持大多数RDBMS,但它可能很繁琐,因为没有很多真正好的免费代码生成器可以使用(不能代表虽然非*的)。

  • SubSonic - A good compromise between NHibernate and LINQ to SQL. It doesn't support as many RDBMSes as NHibernate, but it works with most of the ones you'd encounter in the business world.
  • SubSonic - NHibernate和LINQ to SQL之间的良好折衷。它不支持与NHibernate一样多的RDBMS,但它适用于您在商业世界中遇到的大多数RDBMS。

TL;DR: NHibernate if you need to have a lot of control over the database or need to support something obscure. SubSonic if you need to work with something other than SQL Server. LINQ to SQL if you just want to run against SQL Server.

TL; DR:NHibernate如果您需要对数据库进行大量控制或需要支持一些模糊的东西。 SubSonic如果您需要使用SQL Server以外的其他东西。 LINQ to SQL如果你只想对SQL Server运行。

#7


Since you are using .NET 3.5, I recommend LINQ.
LINQ reuires only that IEnumerable and IQueryable interfaces are implemented.
That means it is not limited to relational data.
Alse see the article ORM in .NET 3.5

由于您使用的是.NET 3.5,我推荐使用LINQ。 LINQ仅要求实现IEnumerable和IQueryable接口。这意味着它不仅限于关系数据。另请参阅.NET 3.5中的ORM文章

#8


For the free and open source route, NHibernate is pretty hard to beat. It's a mature ORM with a very active community and plenty of support. There is an initial learning curve there with NHibernate, however, I think it's well worth the effort you might invest in it.

对于免费和开源的路线,NHibernate很难被击败。这是一个成熟的ORM,拥有非常活跃的社区和充足的支持。 NHibernate有一个初步的学习曲线,但是,我认为你可能投入的努力是值得的。

If you want to stay within Micrsoft's .NET world, LINQ is a great technology to learn, and not just LINQ2SQL (which as you say, isn't a full-blown ORM anyway) as LINQ can be applied to objects, XML and basically anything that's IEnumerable/IQueryable.

如果你想留在Micrsoft的.NET世界中,LINQ是一个很好的学习技术,而不仅仅是LINQ2SQL(正如你所说,它不是一个完整的ORM),因为LINQ可以应用于对象,XML和基本任何IEnumerable / IQueryable。

For the future, I'd recommend Entity Framework (again, within the Microsoft world). There has been a few scary sounding announcements from the LINQ2SQL team within Microsoft which seem to suggest that all future development effort will be put into Entity Framework rather than LINQ2SQL. There is a certain amount of overlap of those technologies anyway. Certainly, I don't believe that LINQ (speaking generally) is going away any time soon, but I'd be careful of investing for the long term in LINQ2SQL. Entity Framework is still relatively new, and under active development, so expect to see EF mature in the coming months/years.

对于未来,我建议实体框架(再次,在微软世界内)。微软内部的LINQ2SQL团队发布了一些可怕的声音,似乎表明所有未来的开发工作都将放入实体框架而不是LINQ2SQL。无论如何,这些技术存在一定程度的重叠。当然,我不相信LINQ(一般来说)很快就会消失,但我会小心在LINQ2SQL中进行长期投资。实体框架仍然相对较新,并且在积极开发中,因此期望EF在未来几个月/几年内成熟。

So, right at this moment, LINQ2SQL is great and you can get up and running with it quite quickly without necessarily having to dive into the inner workings of it (i.e. expression trees etc.) but for the future, I'd recommend Entity Framework/NHibernate as I believe these two ORM's will be the ones in majority use over the next few years by most .NET dev teams.

所以,就在这时,LINQ2SQL很棒,你可以很快地启动和运行它,而不必深入研究它的内部工作(即表达式树等),但对于未来,我建议实体框架/ NHibernate我相信这两个ORM将成为大多数.NET开发团队在未来几年内大多数使用的ORM。

Of course, that said, there are a myriad of different ORM solutions out there, and I doubt any one of them will be a one-size-fits-all solution, so you really have to examine each of them and see which is most suitable for the specific project that you're working on.

当然,那里说有很多不同的ORM解决方案,我怀疑它们中的任何一个都是一个通用的解决方案,所以你真的必须检查每个解决方案,看看哪个是最适合您正在进行的特定项目。

#9


Checkout XmlDataMapper a simple free ORM (LGPL Licence) which leaves a low memory footprint compared to the other giants.
The sample project provided should be good enough to get started.

结帐XmlDataMapper是一个简单的免费ORM(LGPL许可证),与其他巨头相比,它的内存占用量较低。提供的示例项目应该足够好以便开始。

To integrate XmlDataMapper all you need to do is 4 little steps

要集成XmlDataMapper,您需要做的只有4个小步骤

  1. Create a Business Entity / DTO for the tables
  2. 为表创建业务实体/ DTO

  3. Create an XML File with the mapping information between the table and the DTO.
  4. 使用表和DTO之间的映射信息创建XML文件。

  5. Specify the DTO and xml file in the configuration.
  6. 在配置中指定DTO和xml文件。

  7. Just call the DTOConverter.Convert(dataReader) and other such methods to convert your database record to DTO / Business Entity
  8. 只需调用DTOConverter.Convert(dataReader)和其他此类方法将您的数据库记录转换为DTO / Business Entity