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后是延时加载,应该是贪婪加载才对,不知是什么原因请给予解答,谢谢
你应该在where 之前加include
where 之前加include 效果也是延时加载
这写的有点,看不太懂