Click here to Skip to main content
15,889,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 28-Dec-12 1:30am
v2
Comments
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??
[no name] 28-Dec-12 5:47am    
i mean various DB server...
like oracle , MSsql server, mysql.
i want to use same project in these 3 database server
thanks..

1 solution

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.
 
Share this answer
 
Comments
[no name] 28-Dec-12 6:24am    
thanks for answer...

i didn't understand it...
i know java hibernate in this we create hibernate mapping file that is xml file and also create single hibernate configuration file that is also xml.. in this we can create hibernate mapping xml file in such a way that support different database server like orace and mySql and sqlServer.. then if i want to switch database server from oracle to sqlServer i have to change only hibernate configuration xml file and only have to chance connection class like that.. i dont need to change hibernate mapping class.. in such a way i can switch one database server to another database server to changer few lines with no problem.

if such a approach is present in Nhibernate .NET. that only i can changer only database configuration like connection string and connection class.. and can i switch MS Sql to my Sql to change few lines in hibernate configuration file ?
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.
[no name] 28-Dec-12 6:55am    
again i didnt understand u.
it is possible in java hibernate..
how can i do it in Nhibernate .NET ?
or it is not possible ?
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!!!
https://skydrive.live.com/redir?resid=BF850F36B9E30F29!4507&authkey=!AKPW5f3sM0xm0ig
[no name] 28-Dec-12 9:43am    
sorry for my language u don't understand.
but i want to know answer in the form or only (YES OR NO)

1) i write application using NHibernate with configuration MS Sql server.
2) application is completed.

now i want to run this application on MySql database server.

is it possible without recompile application

Thanks

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900