rupeshtiwari / NHibernate.Asp.Net

Showing sample to use nhibernate using asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NHibernateAsp.Net (Using NHibernate with Asp.net)

This is a sample project where I have added below things:

  • Simple NHiberanate uses.
  • Repository Pattern using NHibernate.
  • Test Project to test all samples
  • Using DI to inject Session object

To Run Project

Please create a database named as "NDemo" inside the SQL Server. I have used SQL2012 express edision.

Notes on NHibernate

  1. Database has to be created manually.
  2. Fluent API can be written to do Mapping install (FluentNHibernate version="1.4.0.0" targetFramework="net35" )
  3. Tables can be generated by Code First & Fluent APIs.
  4. Each complex type must have its own Mapper for reusability or it can be merged in Entity Mapper
  5. Each Entity must have its own Mapper
  6. Each Entity must have one internal empty constructor only if it has any non-empty constructor.
  7. Each Persisted Property has to be marked as Virtual.
  8. Private setter on property will not work ( it has to be protected/public internal set)
  9. Any setter method has to be marked as virtual.
  10. Batch insert is supported. However, Id has to be of type of GUID.
  11. Inheritance Not Supported For Value Objects, it has to be Entity.

Common Error

No persister for: User

Solution:
  1. Check if there is no Mapper class defined for that Entity or Component
  2. Make sure Mapper Class must be public

About

Showing sample to use nhibernate using asp.net


Languages

Language:C# 100.0%