Getting Started with NHibernate for Asp.net
Here I introduce you with use of n-Hibernate with Asp.net
Before we start ..I want you to have some basic idea about n-Hibernate framework.
Object relation
mapping is one very interesting part in n-hibernate framework, now .net developers can use easily, it saves lot of time.
In n-Hibernate we can map our database object with our business layer by using a simple xml config file. and database interaction (insert, update, delete, select) become one line job .
Now look at the steps to implement n-hibernate in asp.net.
First you download the NHibernate binaries from the official site.
download folder with the –bin.zip extension
You will get the following assemblies in the bin folder.
NHibernate.dll – this is the main assembly.
Iesi.Collections.dll – It provides data structures (such as sets) implementation which are not provided by the .NET
log4net.dll – this is used for logging
Castle.Core
Castle.DynamicProxy2 – used for generating proxies, (support features such as lazy loading)
Now look at the Configuration & Implementation Steps
| 1. | Create a web project |
| 2. | Place all .dll(s) in the bin folder of your project. |
| 3. | Copy the follwing setting in your web.config |
 | Nhibernate Configuration in web.config file |
| <?xml version="1.0" encoding="utf-8" ?>
| | 1:<configuration>
| | 2: <configSections>
| | 3: <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
| | 4: </configSections>
| | 5:
| | 6: <nhibernate>
| | 7: <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
| | 8: <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
| | 9: <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
| | 10: <add key="hibernate.connection.connection_string" value="Server=MyServer_SQL2005;initial catalog=myDatabase;User ID=myUID;Password=myPass;Integrated Security=SSPI" />
| | 11: </nhibernate>
| | 12:</configuration>
| | 13: |
|
Now look at the
data access methods
Asp.net, Ado.net, .Net Remoting, .Net
Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML