何时使用ORM工具......? [英] When to use ORM tools...?
本文介绍了何时使用ORM工具......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾在一个项目中工作,其中大多数业务逻辑都在存储过程(SQL 2005)中。所以我们只是用来从数据访问层调用存储过程。
我对这个ORM概念很新。对它有一个公平的理解。我已经通过了实体框架模型,NHibernate,但无法理解我们可以利用它们的情况。
能否请你给我一个实际的例子,其中我们可以有效地使用这些ORM工具....
I have worked in a project where most of the business logic was in Stored Procedures (SQL 2005). So we just used to call the stored procedure from Data Access Layer.
I am very new to this ORM concept. Have a fair understanding of it. I have gone through Entity Framework Model, NHibernate, but could not understand the situation where we can make use of them.
Can you please suggest me a practical example, where we can effectively use these ORM tools....
推荐答案
使用ORM的最佳时间是:
0)当你不在乎程序执行得多么糟糕
1)你愿意放弃一定的灵活性
2)你肯定并且确定地球上没有办法让你需要修改生成的代码。
The best time to use an ORM is:
0) When you don't care how badly a program performs
1) You're willing to give up a certain amount of flexibility
2) You know for sure and certain that there's no way on this earth that you're going to need to modify the generated code.
您正在寻找一个问题,以解决已经决定的解决方案!?是的,当然是你,因为你想知道该死的东西是如何实际使用的 - 这是一个值得称赞的想法,但很多人遗憾地错过了。
这里有一些指导原则:
1.您编写的应用程序是否需要与数据库无关?
2.您是否在开发需要的产品?支持不同的数据库?
通常,在数据库模式保持*几乎*不变的情况下,O / R映射器可以为数据库结构提供一些增益来实现对象序列化和反之亦然。
这并不意味着上述所有解决方案都是O / RM工具,但只是说O / RM工具适合在这些工具中进行评估场景。
请注意,许多类似的情况也可以通过写得很好的DAL解决。
如果您在为新项目设计解决方案时理解了理论并保持开放,那么您可能会看到O / R M的一些很好的用途。
You are looking for a problem to fix with a solution already decided!? Yes, of course you are, because you want to learn how the damn thing is used practically - this is a commendable idea, but sadly missed by many.
Here are a few guidelines:
1. Does the application you write need to be database agnostic?
2. Are you developing a product that needs to support different databases?
In general, where a DB schema remains *almost* constant, an O/R mapper may provide some gains for DB structure to Object serialization and vice versa.
This does not mean that solution for all of the above is O/R M tool, but simply that O/R M tools are appropriate to be evaluated in these scenarios.
Be aware that many similar situations can also be addressed through a well written DAL.
If you have understood the theory and keep your mind open when designing solutions for new projects, you may see some good uses for O/R M.
这篇关于何时使用ORM工具......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文