问题
I have a class which I want to add a property with using formula attribute.
Here is the mapping that I use in mapping file.
<property name="CurrentUserVote" type="Climate.Domain.Vote, Climate.Domain" formula="(select v from Vote v where v.AchievementId=Id and (v.IP=:CurrentUserVoteFilter.CurrentUserIP))"></property>
As you see, I want this property to be an object which refers to class that already has an nhibernate mapping. But this mapping gives a mapping exception;
Could not determine type for: Climate.Domain.Vote, Climate.Domain, for columns: NHibernate.Mapping.Formula( (select v from Vote v where v.AchievementId=Id and (v.IP=:CurrentUserVoteFilter.CurrentUserIP)) )
Is it possible to map a property with formula attribute to a class?
Thanks in advance.
回答1:
The property type must be a IUserType. See
- NHibernate property mapping: columns and formula
- http://blog.khedan.com/2009/01/eager-loading-from-formula-in.html
来源:https://stackoverflow.com/questions/2403915/how-to-map-a-property-with-formula-in-nhibernate