Beispiel #1
0
 /// <summary>
 /// 获得排序字段集合
 /// </summary>
 /// <param name="para"></param>
 /// <returns></returns>
 public static IReadOnlyDictionary <string, Direction> GetOrderings(this IODataParameter para)
 {
     if (para is ODataParameter opara)
     {
         return(opara.Orderings);
     }
     return(ODataParameter.ToOrderingDictionary(para.OrderBy));
 }
        /// <summary>
        /// OData查询,支持 top, skip, orderby
        /// </summary>
        /// <typeparam name="T">数据源类型</typeparam>
        /// <param name="query">数据源</param>
        /// <param name="top">加载的数据量</param>
        /// <param name="skip">跳过的数据量</param>
        /// <param name="orderby">排序信息</param>
        /// <returns>排序分页后的数据</returns>
        public static IQueryable <T> ODataQuery <T>(this IQueryable <T> query, int top, int skip, string orderby)
        {
            IReadOnlyDictionary <string, Direction> orderings = ODataParameter.ToOrderingDictionary(orderby);

            return(ODataQuery(query, top, skip, orderings));
        }