首页 新闻 会员 周边

entity framework 加载问题

0
[待解决问题]
public IEnumerable<T> GetPagedList(ISpecification<T> spec, int pageIndex, int pageSize, out long total, string orderBy, bool descending, string includeProperties)
        {            
            IQueryable<T> source = dbset.Where(spec.SatisfiedBy());
            foreach (var includeProperty in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                source.Include(includeProperty);
            }
            total = source.Count();
            if (orderBy != null)
            {
                source = source.IncludeOrderBy(orderBy, descending);
            }
            return source.Skip((pageIndex - 1) * pageSize).Take(pageSize).AsEnumerable<T>();               
        }

这是数据访问层代码,在服务层已经调用了tolist(),为什么include后是延时加载,应该是贪婪加载才对,不知是什么原因请给予解答,谢谢

J-Pei的主页 J-Pei | 初学一级 | 园豆:185
提问于:2012-08-06 15:27
< >
分享
所有回答(2)
0

你应该在where 之前加include

gunsmoke | 园豆:3592 (老鸟四级) | 2012-08-07 10:09

where 之前加include 效果也是延时加载

支持(0) 反对(0) J-Pei | 园豆:185 (初学一级) | 2012-08-07 11:13
0

这写的有点,看不太懂

jerry-Tom | 园豆:4077 (老鸟四级) | 2012-08-07 11:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册