我試圖映射以下結構:由(select top 1 HistoryDate from History where ContentID = {tagid} && Type = 'Activated' order by HistoryDate desc
不知道了如何使用功能NHibernate從自定義查詢的對象上的屬性
我實際上是填充
public class Tag {
public Guid Id {get;set;}
public DateTime ActivatedDate {get;set;}
}
public class History {
public Guid Id {get;set;}
public TypeEnum Type {get;set;}
public Guid ContentID {get;set;}
public DateTime HistoryDate {get;set;}
}
Tag.ActivatedDate真的不知道如何用Fluent NHibernate映射這個。
我的映射是:
public TagMapping() {
Table("Tags");
Id(x => x.Id)
}
public HistoryMapping() {
Table("History");
Id(x => x.Id);
Map(x => x.Type).CustomeType<TypeEnum>();
Map(x => x.ContentID);
Map(x => x.HistoryDate);
}
我不知道如何映射Tag.ActivatedTop
基本上在尋找:
SELECT tag.Id,
(select top 1 HistoryDate from History
where ContentID = tag.Id
AND Status = 'Activated'
order by HistoryDate desc) As ActivatedDate
FROM Tags tag
你的意思是ActivatedDate在「我是n確定如何映射Tag.ActivatedTop「? – brainimus 2011-02-02 21:57:42