如何在NHibernate中用公式映射属性? [英] How to map a property with formula in NHibernate?

查看:100
本文介绍了如何在NHibernate中用公式映射属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要使用公式属性添加属性的类.

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>

如您所见,我希望此属性是一个对象,它引用已经具有nhibernate映射的类.但是此映射提供了映射例外;

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?

提前谢谢.

推荐答案

属性类型必须是IUserType.参见

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

这篇关于如何在NHibernate中用公式映射属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆