ORM有什么优点? [英] What is so great about ORM?

查看:78
本文介绍了ORM有什么优点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我对墙碰到头了,希望有人能帮忙移开墙或阻止我的头移动!

So I'm having a head against the wall moment and hoping somebody can come help either remove the wall or stop my head from moving!!

在过去的3/4周中,我一直在调查ORM是否准备好进行新项目. ORM必须映射到现有的,大型且老化的SQL数据库.

Over the last 3/4 weeks I've been investigating ORM's in readyness for a new project. The ORM must map to an existing, large and ageing SQL database.

所以我尝试了Subsonic.改装后,我真的很喜欢v2和v3与VB一起很好地工作,并且SQL中的命名模式运行正常.但是,由于缺乏单独的实体属性名称和列名称的灵活性,这使我难以为继(对不起,Rob).

So I tried Subsonic. I really liked v2 and v3 after modding to work nicely with VB and named schemas in SQL was running OK. However, its lack of flexibility of having separate entity properties names vs column names had me pulling my hair out (sorry Rob).

我尝试了Entity Framework,但是我发现它在某些方面缺少其他领域.

I tried Entity Framework but I found like others it lacking in certain areas.

所以我咬紧牙关,尝试了nHibernate,但是大约一个星期后按我喜欢的方式工作(在Codesmith的帮助下为我生成类/hbms),我对启动所需的时间感到沮丧(构建一个config对象),尽管尝试了许多技巧来减少此时间.

So I bit the bullet and tried nHibernate but after a week or so getting it working how I liked (with help from Codesmith to generate classes/hbms for me) I'm frustrated with the time it takes to startup (build a config object), despite trying a number of tricks to reduce this time.

我基本上是在建立可以在应用程序和网站之间共享的DAL类之后.我在树错树上吠叫吗?对于具有100个表的旧项目,我应该回到ado.net并使用DTO吗?啊!

I'm essentially after building a DAL class that I can share between apps and websites. Am I barking up the wrong tree? For a legacy project with 100s of tables should I go back to ado.net and use DTOs? Aarrgh!

抱歉,我对问题的担保方式不满意.我没有太多的头发了,我想保留自己的头发!

Sorry for the ranty style of question. I don't have much hair left and I'd like to keep what I have!!

谢谢,埃德

PS.我应该补充一点,我非常了解SQL,并且不怕动手编写快速查询.如果有什么需要,我不需要从SQL隐藏

PS. I should add that I know SQL very well and not scared of getting my hands dirty to write fast queries. If anything I don't need to be hid from SQL

推荐答案

ORM让您:

  1. 要将表行映射到对象,这是面向对象编程的可行部分.
  2. 自动导航对象关系
  3. 要轻松添加,编辑和删除表行
  4. 无需考虑联接即可以更直观的方式查询数据库(这取决于ORM和查询方法)
  5. 透明地处理L1和L2缓存.

如果您不使用ORM,则必须手动处理以上所有内容.

All of the above would have to be handled by hand if you werent using ORM.

PS:对于NHibernate的启动时间,我同意Dmitry的意见(请参阅问题注释).此外,您是否尝试过 Fluent NHibernate ?流利的NHibernate非常容易.第一次映射数据库时,我不敢相信自己的眼睛.它比DevExpress XPO之类的专有ORM更加容易.

PS: I agree to Dmitry as to the startup time of NHibernate (see question comments). Besides, did you try Fluent NHibernate? Fluent NHibernate is impressively easy. I couldn't believe my eyes when I first mapped a database. It's even easier than proprietary ORMs like DevExpress XPO.

这篇关于ORM有什么优点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆