首页 新闻 赞助 找找看

ef6 查询出来的IQueryable 遍历后自动更改

0
悬赏园豆:10 [已关闭问题] 关闭于 2016-04-13 14:37

定义了一个查询的方法

public IQueryable<T> FindList<T>(Expression<Func<T, bool>> whereLamdba, bool isAsc, Expression<Func<T, int>> orderLamdba) where T : class
        {
            var _list = nContext.Set<T>().Where(whereLamdba);
            if (isAsc) _list = _list.OrderBy(orderLamdba);
            else _list = _list.OrderByDescending(orderLamdba);

            return _list;
        }

 

public List<comment> CommentList(int type, int id)
        {
            var commentList = FindList<comment>(c => c.type == type && c.for_id == id, false, c => c.id).ToList();
            foreach (var item in commentList)
            {
                item.users = db.Find<users>(u => u.id == item.user_id);
            }
            return commentList;
        }

 这里读出数据后循环遍历,在循环中并没有更新 commentList,但是commentList会自动把users的数据更新,请问这个是IQueryable的特性吗还是什么原因

喜悦如莲的主页 喜悦如莲 | 初学一级 | 园豆:146
提问于:2016-04-09 16:27
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册