我想將NHibernate CreateCriteria轉換爲NHLambdaExtensions條件,但是我收到了一些我不知道如何解決的錯誤。NHibernate Lambda擴展 - CreateCriteria問題
NHibernate的標準是這樣的:
var departments = DepartmentService
.CreateCriteria()
.CreateAlias("Goals", "goal")
.Add(Expression.Eq("goal.Company.Id", companyId))
.Add(Expression.Eq("goal.Program.Id", programId))
.List<Business.Department>();
,我試圖創建看起來像這樣NHLambdaExtensions標準:
Business.Goal goalAlias = null;
var departments = DepartmentService
.CreateCriteria()
.CreateAlias<Business.Goal>(g => g.Department,() => goalAlias)
.Add<Business.Goal>(g => g.Company.Id == companyId)
.Add<Business.Goal>(g => g.Program.Id == programId)
.List<Business.Department>();
我得到的錯誤是「無法解析財產部:商業部「。這個錯誤顯然與「g => g.Department」有關,並且原始NHibernate查詢中沒有任何東西類似,但沒有重載不包含該表達式。
對不起,十億retags:
實際上,你可以更有效地爲寫這篇文章。我試圖爲未被截斷的lambda表達式獲得正確的標籤。 – ddc0660 2009-09-14 18:01:34