Click here to Skip to main content
12,396,461 members (70,909 online)
Rate this:
Please Sign up or sign in to vote.
See more: NHibernate
if i build project using Nhibernate .net then after completing project can i switch one database server to another database server only by changing single configuration file ?

if it is possible then how can i do by Nghibernae .NET.

i am developing project but i want to use same project in multiple database server.. is possible in java hibernate but i want to use .NET platform. so is it possible in Nhibernate .NET. ?
Posted 27-Dec-12 23:27pm
Updated 28-Dec-12 1:30am
Oleksandr Kulchytskyi 28-Dec-12 5:33am
So what do you meand in term of "multiple database server"?
Is it the same server architecture , but in differ location???
Or you mean various DB servers??

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

thus, based on the latest updates from U.
My approach lies in next.
You might to create generic repository interface and leverage it for basic CRUD operation , also you can leverage it with conjunction of UnityOfWork pattern(for example to commit all affected entities)....

After that you might implement specific entity repositories by inherits that generic repo interface and adjust each type of repo for concrete Database architecture.
so, for example in a result you will have
DepartmentRepoSqlServer,DepartmentRepoOracle... and so on.
Oleksandr Kulchytskyi 28-Dec-12 6:28am
Ohhh , sorry for my inattentiveness. Now i have caught what you mean..
Yep of course this things are still relevant for NHibernate.
Oleksandr Kulchytskyi 28-Dec-12 7:56am
Sorry for so late response....
But if be honest, in my turn, i do not understand U..
What did you expect? If you are expected that i will write a whole explanation turtorial about implementing the same func like Java Hibernate but in consideration of NHibernate...
Do you know how much time it can takes?
I have shared to you from my Skydrive a link to a book, please read it!!!!4507&authkey=!AKPW5f3sM0xm0ig
Oleksandr Kulchytskyi 28-Dec-12 9:47am
1) i write application using NHibernate with configuration MS Sql server.-
In which form this configuration is persisted? in case of FLUENT API, my answer is NO, otherwise (in case of xml config), - YES.

NHibernate is some aspect is a replication (porting code from JAVA platform to C#) + some complementary changes have been added (such as LINQ - which is not characteristic of JAVA)
Oleksandr Kulchytskyi 28-Dec-12 9:50am
You are welcome.
Oleksandr Kulchytskyi 28-Dec-12 6:24am
Furthermore, in you injected in your solution such things as DI, and IoC,
you can achive functionality of replacing of usage differ DB servers on runtime , for example using config files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100