tags:

views:

647

answers:

11

I'm currently working on putting together a fairly simple ORM tool to serve as a framework for various web projects for a client. Most of the projects are internal and will not require massive amounts of concurrency and all will go against SQL Server. I've suggested that they go with ORM tools like SubSonic, NHibernate, and a number of other open source projects out there, but for maintainability and flexibility reasons they want to create something custom. So my question is this: What are some features that I should make sure to include in this ORM tool? BTW, I'll be using MyGeneration to do the code generation templates.

+1  A: 

You need to go the nHibernate style, in my experience, and have it so that you have some kind of map, between your objects and the database. This allows your objects to have some things that are hard to represent in a database but are easier represented in POCOs.

Generation gets you started, by giving you classes that meet your schema, but if you plan on maintaining anything or testing anything, mapping is pain now for pleasure later.

Subsonic is a great model, and its open source, if you must go generation, use their templates in myGeneration to get a leg up.

BTW: I've done what you are doing, and I ended up with something very similar to subsonic, and now advise my clients to take the subsonic source, and fork it for themselves.

DevelopingChris
+22  A: 

For the love of all that's holy (and the women and the children), do everything possible to convince them not to go with a custom O/RM solution. Why are people wanting to re-invent the wheel when there are perfectly-good, open-source wheels already in existence?!?!

Jason Bunting
Well, I totally agree...I'm a big fan of both SubSonic and NHibernate, but in this case I think the Client is going to pretty much always push back.
JC Grubbs
+2  A: 

IMO writing your own OR/M is one the worst design decisions you could ever make. "maintainability and flexibility" are reasons exactly NOT to write your own OR/M.

Please read See 25 Reasons Not To Write Your Own Object Relational Mapper, and see if your client really wants to pay what it costs to build something like NHibernate ($7.6M) or SubSonic ($1.5M). Because, like ChanChan said above, you will end up with something similar to that.

Mauricio Scheffer
A: 

Maybe just maybe, you need badly some "features" that do not exist yet in the existing solutions. Maybe you need something simpler also. 1.5$ for Subsonic is simply outrageous. Maybe you want to use POCO. Maybe you want to use the stuff easily in a 3 tier scenario. Maybe you don't want to support ALL RDBMS on the planet, so you can hardcode and optimize the code just for your target. Maybe you want to implement smarter object tracking. Maybe some design decisions made by the existing orms drive you crazy....

I myself am using a custom orm developed by me myself and i, and i am satisfied that i did it. There is no hidden dragon under the carpet, no surprise scenario. My orm does exacty what i want it to do, nothing less, nothing more.

Liviu
+7  A: 
Dale Halliwell
A: 

No-one has mentioned it yet; but go with LLBLGen. You may customise the template as you like, and you may also, obviously, write your own custom code in the generated classes. Buy it. You will never look back, and you will be saying "Thank you silky!" when it consistently works beautifully. (I didn't write it, but I love it). If it doesn't work out for you, you may also say "Damn you silky!". But that's unlikely, however I do offer it as an option.

The only bad thing I noticed about LLBLGen has been the support for switching between Databases/servers on the fly. It doesn't support a feature that I'd like; namely the ability to detect that a given entity you retrieved doesn't "exist" in a new database that you've switched to. But this is a rare case.

I suggest LLBLGen, because I was in the process of writing my own OR/M when I came across it. Never looked back.

Noon Silk
+1  A: 

There's a bunch of posts by Davy Brion (an NHibernate committer) who is for some reason also forced to write a custom ORM for a client.

Some of the things he covers are:

  • Mapping Classes To Tables
  • Out Of The Box CRUD Functionality
  • Hydrating Entities
  • Session Level Cache
  • Executing Custom Queries

Definately worth checking out, if you MUST go down this path: Build Your Own Data Access Layer Series

Brendan Kowitz
A: 

Your job as a consultant (sounds like that's what you are) is to leverage your expertise in implementing for your clients a solution that fits their desires with a minimum cost and time investment.

If they want to build and sell an OR/M. The go to town making one. If they want anything else, use one that already exists to get the job done.

If they insist on spending money, buy an existing one (I won't name any, but there exist some good ones that are not free).

SnOrfus
A: 

Hi,

  • Second level cache

    Allows you maintain entities instances in-memory

  • Automatic dirty-checking

    Allows you updates changes in an object without loading it.

  • Powerful query language

  • Powerful cascade operation

  • Powerful primary key generator strategy

    ORM framework will pickup best primary key generator strategy according to target database

  • Support to composite elements

  • Support to events

    onSave, onUpdate and so on

  • Good documentation and reference books

  • Support to conversational state

regards,

Arthur Ronald F D Garcia
A: 

Just read this http://www.15seconds.com/issue/080103.htm

programmernovice
A: 

Hello. Try to use Devart LinqConnect - all of the LINQ to SQL features and wide support of the most popular database servers - Oracle, MySQL, Postgre, SQL Server, and SQLite. Incredible Visual Modeling tool, advanced monitoring tool, high quality support - as a result i've learned it only in three weeks during my project execution.

JackD