I have an NHibernate entity that looks like this:
public class Offender
{
public virtual string FName { get; set; }
public virtual string MName { get; set; }
public virtual string LName { get; set; }
public string FullName
{
get
{
return FName + " " + MName + " " + LName;
}
}
}
Fullname is a convenience property, and it isn't in the database. But NHibernate doesn't like the property being there and throws this exception:
The following types may not be used as proxies:
mPSOR.Data.Entities.SORPerson: method get_FullName should be 'public/protected virtual' or 'protected internal virtual'
Is there any way to include a helper property like that? Or do I have to put computation like that when compiling a DTO or in my view?
NHibernate needs all properties to be virtual...even "fake" properties like your "FullName".
Just make it virtual and it will work:
public virtual string FullName
{
}