开发者

NHibernate & Linq - "could not resolve property"

Mapping-File:

<?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; set; }

public virtual DateTime Datum { get; set;}

public virtual DateTime Gültig { get; set; }

public virtual int Id { get; set; }

public virtual string ISOCode { get; set; }

public virtual int Kursart { get; set; }

public virtual double RealerKurs { get; set; }

public virtual int WährungstabkurseId { get; set; }

...

I get a NHibernate.QueryException ("could not resolve property: Datum.Date of: DaVinci.Domain.Waehrungskurs") when i call the following function:

    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();
    }

When i delete the search-condition "WK.Datum.Date == datum.Date", the function works fine.

Any ideas why the property cannot be found?


The date-property of date time is not found because it's not implemented. Please write a patch for this class


The property isn't there.

Try replacing: WK.Datum.Date == datum.Date

with

WK.Datum == datum.Date
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜