I have the following property on a class persisted with NHibernate:
public virtual string Code
{
get { return Id.ToString("SP000"); }
}
However I've come to do this, which of course doesn't work:
Session.Linq<MyType>().Where(x => x.Code.Contains(searchTerm));
So, is it possible to store Code in the database and have NHibernate manage the
.ToString("SP000")
to set Code, when ID is set?
Edit: I guess I need an interceptor, but I'm not sure how to implement what I need. Any help appreciated
Thanks
Andrew