我需要使用 NHibernate 从数据库返回指定日期的 ACC_INTERVAL_ID 属性值列表,以获取可用的时间间隔。NHibernate 版本是 2.1.2.4000
认证记录:
public class AccreditationRecord : DomainObject
{
public AccreditationRecord()
{
Date = DateTime.Now;
}
/// <summary>
/// Интервал встречи
/// </summary>
public virtual AccreditationTimeIntervalEnum Interval { get; set; }
/// <summary>
/// Дата встречи
/// </summary>
public virtual DateTime Date { get; set; }
/// <summary>
/// Название компании
/// </summary>
public virtual string CompanyTitle { get; set; }
/// <summary>
/// Название выставки
/// </summary>
public virtual string ExhibitionTitle { get; set; }
/// <summary>
/// Комментарий аккредитируемого к форме
/// </summary>
public virtual string Comment { get; set; }
}
映射:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Mvk.Kvc.Domain" assembly="Mvk.Kvc.Domain">
<class name="AccreditationRecord" table="KVC_ACCREDITATIONS" lazy="false" >
<id name="ID" column="ID_ACCREDITATIONS" type="Int32" unsaved-value="-1">
<generator class="identity"/>
</id>
<property name="Date" column="ACC_DATE" type="DateTime" />
<property name="CompanyTitle" column="COMPANYTITLE" type="AnsiString" length="512" />
<property name="ExhibitionTitle" column="EXHIBITIONTITLE" type="AnsiString" length="512" />
<property name="Comment" column="COMMENT" type="AnsiString" length="1000" />
<property name="Interval" column="ACC_INTERVAL_ID" type="AccreditationTimeIntervalEnum" />
</class>
</hibernate-mapping>
我在存储库中的方法:
public virtual IList<int> GetFilledIntervals(DateTime selectedDate)
{
DetachedCriteria query = DetachedCriteria
.For(typeof(AccreditationRecord));
query.Add(Restrictions.Eq("Date", selectedDate));
query.SetProjection(Projections.Id());
return ??????????
}