开发者

Starting on ORMS - Nhibernate

开发者 https://www.devze.com 2022-12-22 05:18 出处:网络
I am starting to delve into the realm of ORMs, particularly NHibernate in developing .NET data-aware applications.I must say that the learning curve is pretty steep and that a lot of things should be

I am starting to delve into the realm of ORMs, particularly NHibernate in developing .NET data-aware applications. I must say that the learning curve is pretty steep and that a lot of things should be noted. Apparently, it actually changes the way you do data-aware applications, manner of coding, development and just about everything.

Anyway, I want to ask if you do set some parameters when deciding to USE or NOT TO USE ORMs in your applications? How do you decide then the approach that one needs to make it valuable to your organization?

The organization which I work for now apparently has made a lot of SQL and Data Access thing running through back end and I must say that these class/methods/procedures have successfully performed their tasks of pro开发者_StackOverflowviding the data which is needed and when it is needed. I think it would be a tremendous effort just to map some of this into ORM and derive the same business value that the company has for the last few years.

Nevertheless, I know that ORM paves the way for applications to talk with database servers, if properly implemented. I must admit that I am at a learning stage and that I would possibly need all the help, resources and the guidance to make this transition. I was also thinking of buying the book from Manning but I feel that with so much changes to NHibernate, the book may be a bit outdated. Perhaps waiting for the Packt book on NHibernate (release on May 2010??) would help me better get up and running.

Kindly share your thoughts. By the way, if you could also point me in a small sample web app which uses NHibernate + Visual Web Developer 2008 Express and SQL Server, that would be highly appreciated.

Thanks.


For me, the short of it is the following:

If you don't use an established ORM, and you develop correctly (meaning you refactor out duplication and look to simplify where you can), you'll wind up building your own ORM through the evolution of your data access layer.

The question then becomes: "Do I want my developers spending time learning the idiosyncrasies of my home-grown ORM or learning those of a well-documented and well-tested ORM?"

Furthermore: "If I'm hiring a new developer, wouldn't it be nicer to bring in a developer that knows the established ORM tool we're using rather than having to train someone up on this thing I built?"

I use NHibernate, particularly Fluent - and it's great; if given the choice, I wouldn't develop on an RDBMS any other way.

To be successful with an ORM you must make sure to normalize correctly, and use the database for it's designed purpose, storing data.


I don't use an orm when:

  1. I don't use a relation database (Relational databases are not the best choice of database for every application)
  2. The database is has a very small amount of tables. (I might need less code without an orm)
  3. I use a very simple database that can map to code with simple naming conventions. (Mapping to dumb DTO classes and all queries like select * from tablename where id=@id)

Learning a good orm is worth the time and effort, it will save you writing a lot of code when you use relational databases a lot. You can find example apps/tutorials/video's about NHibernate on with stackoverflow search. There is another book in progress by manning, maybe it's possible to read it with the early access program.

0

精彩评论

暂无评论...
验证码 换一张
取 消