Linq to Sql versus NHibernate mapping options
I'm pretty much a beginner and I need to figure this out in order to write a college paper, so I need some kind of bootstrap.
I read here and there that NHibernate offers much more flexibility (compared to L2S) when mapping a domain model to a database. Can you write down some tips for what I should research?
Be aware that L2S "does it for you" by creating objects in an extremely large DBML file. You can work with your objects by creating partial classes, but if you decide to try and make any changes to the dbml files, you will be screwed because L2S will either overwrite your changes when they regenerate, or you will have to perform any changes manually in future,
So, you are stuck because it is a terrible idea to change DBML, but because of this, there are limits on what you can do in terms of the properties of your object names. A classic example is using enumerations that are stored as ints in your database. Lets say you have UserType as an enum in your application, in your custom table you probably just store that as an int column named UserType. This is great, except when you create your DBML file, you get a UserType displayed as an int column ... but if you really want the UserType property to return a UserType enumeration, you are forced to either hack DBML ... or change your conventions about the names in your database matches your ORM tool ... none of these are good options.
Whereas nHibernate is just an XML based mapping between YOUR OBJECTS and YOUR database, which gives you significantly more flexibility in how you want to set things up.
another thing to look out for is many-to-many relationships and table-to-subclass / table-to-class mappings, which are specified here:
http://nhibernate.info/doc/nh/en/index.html
I don't believe L2S can handle relationships between subclasses.
Hope it helps,
-Max
source to share