NHibernate& Linq - “无法解决财产问题”

时间:2009-10-20 15:34:25

标签: linq nhibernate

映射-文件:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
               assembly="DaVinci"
               namespace="DaVinci.Domain">
  <class name="Waehrungskurs" table="WAEHRUNGSKURSE">
    <id name="Id" column="ID">
      <generator class="native" />
    </id>
    <property name="ISOCode" column="ISO" />
    <property name="AktuellerKurs" column="AKTKURS" />
    <property name="Kursart" column="KIND_OF_KURS" />
    <property name="WährungstabkurseId" column="WAEHRUNGSTABKURSE_ID" />
    <property name="Departure" column="DEPARTURE" />
    <property name="Datum" column="DATE_TIME" />
    <property name="RealerKurs" column="REALKURS" />
    <property name="Gültig" column="GUELTIG" />    
  </class>
</hibernate-mapping>

Domain.cs:
...
public virtual double AktuellerKurs {get;组; }
public virtual DateTime Datum {get;设置;}
public virtualDateTimeGültig{get;组; }
public virtual int Id {get;组; }
公共虚拟字符串ISOCode {get;组; }
public virtual int Kursart {get;组; }
public virtual double RealerKurs {get;组; }
public virtualintWährungstabkurseId{get;组; }
......

当我调用以下函数时,我得到一个NHibernate.QueryException(“无法解析属性:Datum.Date:DaVinci.Domain.Waehrungskurs”):

    public static Domain.Waehrungskurs GetByISOAndKursartAndDate(string isocode, int kursart, DateTime datum)
    {            

        return (from WK in session.Linq<DaVinci.Domain.Waehrungskurs>()                    
                where WK.ISOCode == isocode
                            &&
                      WK.Kursart == kursart
                            &&
                      WK.Datum.Date == datum.Date
                orderby WK.Id descending
                select WK).First();
    }

当我删除搜索条件“WK.Datum.Date == datum.Date”时,该功能正常。

为何无法找到该物业的任何想法?

2 个答案:

答案 0 :(得分:1)

找不到日期时间的日期属性,因为它未实现。请为this class

编写补丁

答案 1 :(得分:0)

该物业不存在。

尝试替换:WK.Datum.Date == datum.Date

WK.Datum == datum.Date