首页 新闻 会员 周边

NHibernate 的HQL 问题

0
[待解决问题]

类的定义

public  class OperLogEntity<BIE> : Entity

        where BIE : BizInfoEntity
    {
        public OperLogEntity()
        {
            this.OperTime = DateTime.Now;
            this.IPAddress = GetIPUtil.GetClientIPv4();
        }


        /// <summary>
        ///操作时间
        /// </summary>
        public virtual DateTime? OperTime { get; private set; }


        /// <summary>
        /// 操作对象实例
        /// </summary>
        public virtual BIE BizEntity { get; set; }


        /// <summary>
        ///IP地址
        /// </summary>

        public virtual string IPAddress { get; set; }

}

ORM映射:

    public class CustomerPersonLogEntityMap: OperLogMap<OperLogEntity<CustomerPerson>, CustomerPerson>
    {
        public CustomerPersonLogEntityMap()
        {
            Table("CSR_PERSON_LOG");
            Id(t => t.Id, "LOG_ID");
            References(t => t.BizEntity, "CSR_CUSTOMER_ID");
        }
    }

​想使用HQL查询 OperLogEntity<CustomerPerson> 中数据:

 var q = Session.CreateQuery(@"select count(*) from OperLogEntity<CustomerPerson>  as d ").UniqueResult<long>();​

报错:引发类型为“Antlr.Runtime.NoViableAltException”的异常。​

我的HQL应该怎么写?

地瓜@.@的主页 地瓜@.@ | 初学一级 | 园豆:6
提问于:2013-09-03 16:31
< >
分享
所有回答(1)
0

把 select count(*) 改为 select count(d) 试试

dudu | 园豆:31007 (高人七级) | 2013-09-03 21:19

不可以啊!

支持(0) 反对(0) 地瓜@.@ | 园豆:6 (初学一级) | 2013-09-04 09:05

@地瓜@.@: 

试试改为:

@"select count(*) from OperLogEntity<CustomerPerson> d")
支持(0) 反对(0) dudu | 园豆:31007 (高人七级) | 2013-09-04 11:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册