EntityFramework:IQueryable或IEnumerable会在第一时间获得所有结果吗?

use*_*653 1 c# linq-to-entities entity-framework linq-to-sql entity-framework-4

我了解到IQueryable或IEnumerable数据类型不会在第一时间返回结果,只在需要时返回它们.然而,当我在手表检查员中打开那个物体时,我看到所有的物体都在那里.

我的代码是否有任何问题,或只是因为我在手表上调用它而显示?

[当我在监视对话框中查看pendings对象时,我看到了所有列表项,但它不应该在第一个位置加载.我的接近是否有什么问题,或者只是因为我在手表上看到它而显示出来.

 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;
            }
        }
Run Code Online (Sandbox Code Playgroud)

注意:目前我的延迟加载已关闭.

Jus*_*ner 5

第一次迭代结果时会对集合进行评估.

由于您在手表检查器中迭代结果,因此它们会被唤醒.