Nhibernate error :Incorrect syntax near the keyword ‘Function’.

In our database sometimes we have column names which are actually the database keywords . If we want to access such columns from Nhibernate session  , it throws error message “Incorrect syntax near the word :’SOME DB KEYWORD’

 

Mapping :Before :

Mapping :After

Keeping database base reserve keyword in “[ ]”  brackets will fix the error message.

 

You can have look on all my previous Nhibernate posts

 

 

 

 

 

 

 

 

 

 

 

Advertisements

“No Persister For” error in Nhibernate

Hello Friends

I was running into some other problem and I wanted to test some thins so I have quickly created a small solution.I did all the required steps and run it ..and voilaaa…

i have this small cute error (because its a really small text 🙂 ) It says “No Persister for :….

I get this error when try to save object or SaveUpdate any object.  After a while I figured out that forgot to make my Mapping class Public.

And it resolve the problem.

My DataModel Class

namespace NHBData.Model

{

public class Employee

{

public virtual int EmployeeID { get; set; }

public virtual string  EmaployeeName { get; set; }

}

}

 

Mapping file before :

namespace NHBData.Model.Mapping

{

class EmployeeMapping :ClassMap

{

EmployeeMapping()

{            Id(x => x.EmployeeID).Unique();

Map(x => x.EmaployeeName);

}

}

}

Mapping File after

namespace NHBData.Model.Mapping

{

Public class EmployeeMapping :ClassMap

{

EmployeeMapping()

{            Id(x => x.EmployeeID).Unique();

Map(x => x.EmaployeeName);

}

}

}


You can have a look to another annoying error and its solution “LazyLoadException” in nhibernate here

 

Hope this helps to someone..

Have a nice time ..