我了解到 IQueryable 或 IEnumerable 数据类型首先不会返回结果,仅在需要时才返回它们。但是,当我在手表检查器中打开该对象时,我看到所有对象都在那里。
我的代码有什么问题,或者它只是因为我在手表上调用它而显示?
[当我在监视对话框中查看挂起对象时,我看到了所有列表项,但它不应该首先加载。我的接近有什么问题,还是只是因为我在手表上调用了它而显示出来。]
public IQueryable<PurchasePendingView> PurchasePendings() {
var pendings = db.PurchasePendingViews
.Where(m => m.AccountStatusID != StructAccountStatus.Succeed); // when I view it in the watch dialougebox I saw all the list items but it shouldn't load at the first place. Is there anything wrong in my approaching or is it just showing because I had call it on the watch.
if (ApplicationEnvironment.DEBUGGING) {
return pendings;
} else if (IsMobileAccount()) {
var showroom = db.ShowRooms.FirstOrDefault(m=> m.MemberID == employee.MemberID);
if (showroom != null) {
return pendings.Where(m => m.ShowRoomID == showroom.ShowRoomID);
} else {
return pendings.Where(m => m.CountryDivisionID == employee.CountryDivisionID);
}
} else {
//normal salary employee can see every detail
return pendings;
}
}
注意:目前我的延迟加载已关闭。