這裏的建立和組織行給出了它們不能將IEnumerable隱式轉換爲bool的錯誤。我錯過了什麼?在方法結束之前,我不能使用貪婪的操作符。我相信這很簡單,但我看不到它。動態LINQ2Entities查詢無法將IEnumerable轉換爲bool
IQueryable<User> query = context.Users;
if (usvm.EstablishmentId > 0)
query = query.Where(x => x.UserEstablishments
.Where(y => y.UserEstablishmentId == usvm.EstablishmentId));
if (usvm.OrganisationId > 0)
query = query.Where(x => x.UserEstablishments
.Where(y => y.Establishment.OrganisationId == usvm.OrganisationId));
if (!String.IsNullOrEmpty(usvm.Forename))
query = query.Where(x => x.Forename == usvm.Forename);
if (!String.IsNullOrEmpty(usvm.Surname))
query = query.Where(x => x.Surname == usvm.Surname);
if (usvm.DOB != null)
query = query.Where(x => x.DOB == usvm.DOB);
List<User> m = query.ToList();
return ToViewModel(m);
你在哪裏設置usvm? – Rugdr 2014-10-22 11:35:44
這是從控制器傳遞的視圖模型。價值在那裏,所以這不是問題。它正在獲取我無法完成的查詢。 – Lee 2014-10-22 11:37:04