Tag: iorderedqueryable

Dynamic Func <IQueryable ,IOrderedQueryable >表达式

我正在使用这里提到的模式http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in- AN-ASP净MVC应用程序 我正在使用下面的方法来查询EF public virtual IEnumerable Get( Expression<Func> filter = null, Func<IQueryable, IOrderedQueryable> orderBy = null, string includeProperties = “”) { IQueryable query = dbSet; if (filter != null) { query = query.Where(filter); } foreach (var includeProperty in includeProperties.Split (new char[] { ‘,’ }, StringSplitOptions.RemoveEmptyEntries)) { query = query.Include(includeProperty); } if (orderBy != null) { […]

无法将IQueryable 转换为IOrderedQueryable错误

我有以下LINQ代码: var posts = (from p in db.Posts .Include(“Site”) .Include(“PostStatus”) where p.Public == false orderby p.PublicationTime select p); if (!chkShowIgnored.Checked) { posts = posts.Where(p => p.PostStatus.Id != 90); } 最后一行(额外的地方)给了我错误: 无法将类型’System.Linq.IQueryable’隐式转换为’System.Linq.IOrderedQueryable’。 我不确定这意味着什么…… 为什么我收到此错误? 它出现了一次我在查询中添加了“orderby”子句,之前它编译得很好,所以我对所发生的事情有一种预感,但我无法完全理解它。