我有以下查詢工作它得到的結果我想:NHibernate的QueryOver加入無關實體
int associatedId = 123;
MyObject alias = null;
var subQuery = QueryOver.Of<DatabaseView>()
.Where(view => view.AssociatedId == associatedId)
.And(view => view.ObjectId == alias.ObjectId)
.Select(view => view.ObjectId);
var results = session.QueryOver<MyObject>(() => alias)
.WithSubquery.WhereExists(subQuery)
.List();
DatabaseView已被映射爲實際NHibernate的實體(這樣我就可以QueryOver使用它),但它在HBM映射中不與MyObject關聯。
該查詢使用SELECT ... FROM MyObject WHERE EXISTS(此處爲DatabaseView的子查詢)返回IList。我怎麼能重新寫這個來返回相同的信息,但使用JOIN呢?
「不能做Linq」爭用被其他答案推翻 – 2015-08-26 16:26:13