3

Q: This question is about how can i figure or select the convenient ORM to my web application. when beginning a new web application,What are the criteria on which i can consider a specific ORM is better than another one for my project or case(web application)?

another part of my question : when i begin any web application i use three layers:

  1. the DB layer (which contains the connections , and handle the CRUD operations )
  2. the Managers layer(the Data Access Layer) a class for each table on my db (loosely coupled with the previous layer )it contains the CRUD operations for the specific table and the other required operations.
  3. the interface layer..

and i use Object Data source.Is that considered as an ORM (as a concept) or I'm wrong in understanding this concept.

note:I still a beginner in this field ,, and every day i learn more about web development. please i want explanation and suggestions for this point.

Thanks in advance.

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • often i use SQL Server, but sometimes i use mysql or informix.. – Anyname Donotcare Dec 28 '10 at 08:41
  • I work only with linq2sql. As I know linq2sql supports MSSQL only. – Oleg Kalenchuk Dec 28 '10 at 08:48
  • 1
    Entity Framework is a good starting point, particularly for SQL server – MikeAinOz Dec 28 '10 at 08:48
  • Did you consider S#arp Architecture as example for your architecture? in my projects i usually use something like them. – breez Dec 28 '10 at 08:51
  • Oh man I wish people wouldn't suggest S#arp Architecture, it's fail. – Phill Dec 28 '10 at 09:00
  • @Phill, didn't use S#arp before but why do you consider it a fail? Interested to know. – Kris van der Mast Dec 28 '10 at 09:19
  • Just causes more problems than it solves. Attempted to use it on a couple of projects before ripping it out entirely bitting the bullet and starting again (salvaging what we could). Know of other people who have had issues with it too, end up designing around S#arp because it did things differently than they needed. Also I dont like automapping, I prefer to explicitly map everything. Thats personal preference tho. – Phill Dec 28 '10 at 09:29
  • I don't like to use s#arp libs in projects too... you can write own solution with favorite ORM for concrete project and s#arp can be example for it. And i can't say that s#arp is fail - it's working pretty good in many projects... – breez Dec 28 '10 at 09:37
  • I have personally never been a big fan of any of the microsoft ORM solutions, I use sql server and hand code my entities and the the code that gets data from db and populates the entities, i use stored procs for CRUD operations of the data, the db methods take a transaction objects where needed and if it is not null, the command is run on the transaction. It is cumbersome to code, but really easy to maintain and manage. – Mahesh Jan 03 '11 at 11:50
  • @just_name, linq2sql is not good choice, In EF leakages of linq2sql solved also EF is very easy to use. in all if you just depend on linq you have too many problems, handling batch updates in both linq2sql and EF is hard by linq abd in nhibernate is impossible but with native query is easy. – Saeed Amiri Jan 05 '11 at 17:10

8 Answers8

8

As for ORM, it's all about taste. nhibernate and Entity framework is the most common ones.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
5

You will not find the specific selection criteria - this is a matter of taste and preference, but you can find the comparative characteristics here

breez
  • 494
  • 2
  • 13
3

I use Devart LinqConnect for small and medium projects (especially for web projects) and I use Entity Framework for large projects. These products are convenient and flexible and allow you to start quickly. LinqConnect includes providers that allow to work with Oracle, MySQL, PostgreSQL, SQLite. I use 3-rd party providers for Entity Framework customizing.

JackD
  • 597
  • 4
  • 7
1

As mentioned previously by @MikeAinOz that Entity Framework is a good start in which you can connect with other databases as well. This sample is also a good starting point about how program layers:

http://layersample.codeplex.com/releases/view/47627

ShahidAzim
  • 1,446
  • 1
  • 10
  • 15
1

most famous ones are nhibernate and EF, Personally I prefer EF, it's speed is better than nhibernate (via linq), and for working with EF I think Code First is most useful startup.

For selecting which ORM (between EF and nhibernate) you can see this blog by Ayende Rahien, who know good about nhibernate, in this post he said that maturity of nhibernate is better but linq2EF is better than nhibernate, simple sample I can give you is: you have a 2 level master detail, in nhibernate you should do hql to retrieve items with specific criteria from detailed item but in EF you can do it simply, Also in EF we have Entity Functions which are interduced to solve problems, and I hope it will be more useful in future.

Saeed Amiri
  • 22,252
  • 5
  • 45
  • 83
  • Note that at the bottom of Ayende's blog post he states that NH3 (with it's new linq provider) will close the gap regarding Linq performance. NH3 went GA a few weeks ago. I've been using it for a while now, and am very happy with it's performance as compared to NH2. – Brook Jan 04 '11 at 15:05
  • @Brook, did you know nhibernate3 implemented SelectMany in linq? I'm very interested to find a SelectMany how can be changed to work in nhibernate. – Saeed Amiri Jan 04 '11 at 17:15
1

I am reading a book on hibernate by the guys who wrote hibernate and by a broad definition anything that maps a relational model to an object model (ex convert a foreign key to a contained object[s]) is an ORM.

The authors put the ORMs in different category, something like Nhibernate falls in the category of a complete ORM, it generates SQL at runtime for ex..

Some other tools like LLBGen need that static dlls be created by connecting to the DB and then those are used.

When choosing an ORM, you should look at the user base, if the ORM is active, ex..new versions and rapid bug fixes, of late Hibernate is probably the most widely used one, in .net there is Fluent Nhibernate that can configure without xml files, hibernated uses annotated classes for this.

Personally I would advice you to use Hibernate based ORM, in ROR active record is the standard I guess...

Mahesh
  • 1,583
  • 13
  • 18
1

For the Microsoft world stick with ado.net entity framework
For the open source world stick with nhibernate.

basarat
  • 261,912
  • 58
  • 460
  • 511
1

In regard to simple database access, there seem to be a lot of opinions on which is the best way to access a database.

I am currently using NHibernate which works really well in MS Sql and MySql. I have found a blog entry that shows how to connect to MYSQL using Nhibernate here.

The deciding factor for me would be looking at the database you are going to be using and then making the decision from there. Scott Guthrie announced the Code First Framework that uses entity framework version 4. While I know that Entity Framework 4.0 works with Mysql (link), I am not sure about Code First. The tutorial for Code First Development can be found here.

Ultimately I think they all do pretty much the same job although if I were starting out looking at ORMs and wanted something simple I might go with the Code First approach as it seems really easy. BUT I have no experience with it. I have only read up on it.

Hope this helps.

Community
  • 1
  • 1
Steve
  • 50,173
  • 4
  • 32
  • 41