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 proje开发者_运维百科ct or case(web application)?
another part of my question : when i begin any web application i use three layers:
- the DB layer (which contains the connections , and handle the CRUD operations )
- 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.
- 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.
As for ORM, it's all about taste. nhibernate and Entity framework is the most common ones.
You will not find the specific selection criteria - this is a matter of taste and preference, but you can find the comparative characteristics here
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.
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
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.
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...
For the Microsoft world stick with ado.net entity framework
For the open source world stick with nhibernate.
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.
精彩评论