Is it Possible to created Decimal as a Primery key with Auto Incremented from FNH Mapping??
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To achieve auto increment Identity type must be integral int, long, uint, ulong.
ex :
public class User
{
public virtual int Id { get; set; }
public virtual IList Names { get; set; }
}
Id(x => x.ID).Column(“ID”).GeneratedBy.Increment();
for decimal properties :
Id(x => x.ID).Column(“ID”).GeneratedBy.Assigned();
Assign the value while creating a new object. Value should be increment of last generated key in your database.
OR you can just implement a Custom ID Generator for NHibernate.
http://lucisferre.net/2009/07/14/implementing-a-custom-id-generator-for-nhibernate/