zoukankan      html  css  js  c++  java
  • oData 排序字段生成

    跟踪SQL 发现生成的SQL中所有的字段都进行了排序,查看OData原代码,发现如果实体有Key,就按照Key asc 加上指定字段进行排序

    属性 EnsureStableOrdering可以控制是否生成多个字段排序

    Type: System.Boolean

    true value indicates the original query should be modified when necessary to guarantee a stable sort order. A false value indicates the sort order can be considered stable without modifying the query. Query providers that ensure a stable sort order should set this value to false. The default value is true.

                ODataQuerySettings settings = new ODataQuerySettings()
                {
                    EnsureStableOrdering = false
                };
            // Returns a sorted list of all properties that may legally appear
            // in an OrderBy.  If the entity type has keys, all are returned.
            // Otherwise, when no keys are present, all primitive properties are returned.
            private static IEnumerable<IEdmStructuralProperty> GetAvailableOrderByProperties(ODataQueryContext context)
            {
                Contract.Assert(context != null);
    
                IEdmEntityType entityType = context.ElementType as IEdmEntityType;
                if (entityType != null)
                {
                    IEnumerable<IEdmStructuralProperty> properties =
                        entityType.Key().Any()
                            ? entityType.Key()
                            : entityType
                                .StructuralProperties()
                                .Where(property => property.Type.IsPrimitive());
    
                    // Sort properties alphabetically for stable sort
                    return properties.OrderBy(property => property.Name);
                }
                else
                {
                    return Enumerable.Empty<IEdmStructuralProperty>();
                }
            }
  • 相关阅读:
    每日日报
    剑指 Offer 18. 删除链表的节点(LeetCode)
    java的访问权限
    java从键盘输入
    剑指 Offer 22. 链表中倒数第k个节点(快慢指针)(LeetCode)
    面试题 02.03. 删除中间节点(LeetCode)
    21. 合并两个有序链表(Leetcode)
    计算总线数据传输率
    时钟周期、总线周期(机器周期)区别
    书单(个人)
  • 原文地址:https://www.cnblogs.com/xiaoyu369/p/7065965.html
Copyright © 2011-2022 走看看