利用LinQ to Entity Framework上,想利用方法语法实现返回值按照升降序混合的顺序进行排列,
参照下边的示例:
IQueryable<BookmarkDirectory> directories = pContext.BookmarkDirectory
.Where(d => includeVirtual ? (d.Tag == tag) : (d.IsVirtual == false && d.Tag == tag))
.OrderBy(d => d.TreeLevel)
.ThenByDescending(d => d.SystemDefined)
.ThenBy(d => d.ParentID)
.ThenBy(d => d.IsView)
.ThenBy(d => d.Name);
注: 排序规则为-->[TreeLevel升序,SystemDefined降序,ParentID & IsView & Name为升序] |
|