到目前爲止,我想我可以做相關的表:查詢使用EF「包括」包括其中
var num = db.MyTable.Include(x => x.RelatedTable)
.Count(x.idTenant == CurrentTenantID && x.Active &&
x.RelatedTable.SomeProperty.Value == true);
這總是返回零個記錄。 我是否錯誤地認爲包括RelatedTable我可以在where部分使用它?
順便說一下......「SomeProperty」是可爲空的,這就是爲什麼「.Value」。
我正在使用實體框架4.1。 (數據庫優先)
謝謝,我認爲在這種情況下「包含」是強制性的。 – Romias 2012-07-10 15:59:12