User Nhibernate with Legacy database

Topday we will talk little bit more about the Nhibernate topic. If you are new to this topic than

you can have look at  previous post

As its well accepted that Nhibernate is getting really (probably) first choice in applcation development
Its really easy to stary with Nhibernate for a new application development. You have more control
on your application  code and its db realtions .
Well  this doesnt go as smooth with Legacy DB as new application.

I have legacy database and it has many relations which could drive tyou crazy like anything .

Here in this post I will present a quick but very useful ways to map you WIERED realtions in Nhibernate using fluent Nhibernate.

Here is my small datamodel to explain this kinda of mapping

Data model

Mapping

 

Above mapping will create a mapping for the ToolLangTbl.

IF you notice int he mapping we have used CompositId to map such mappings.

Note :

In such cases always implement GetHashCode and Equal methods as below

 

 

If you still have some other wiered database relations and need help to map them ..I can try to help you in it.

Have a nice day ahead !!

 

 

Advertisements

One thought on “User Nhibernate with Legacy database

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s