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

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

Type: System.Boolean

A 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>();
}
}

oData 排序字段生成的更多相关文章

  1. Woocommerce 分类下的产品如何使用ID号来作为默认排序字段

    在给一个客户开发网店系统时使用了WordPress系统的Woocommerce插件 WordPress版本:3.8 Woocommerce版本:2.0.20 如果没有指定排序规则(指定的字段),则Wo ...

  2. sql 分组后查询出排序字段

    select  row_number() over(partition by  CODE order by SEQUENCE) as RowIndex  from Table 注:根据表的CODE 字 ...

  3. 去重 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN

    关键字  ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN 按照分组字段进行排序并标编号 ROW_NUMBER() OVER(PARTITIO ...

  4. EntityFramework动态组合多排序字段

    前言:在使用EF当中,肯定会遇到动态查询的需求,建立一个公共调用的动态组合表达式查询也是必不可少的,以下是建立动态组合多排序字段做个记录,供以后调用 1.建立一个结构,用于多个排序字段组合,这个结构体 ...

  5. sql查询调优之where条件排序字段以及limit使用索引的奥秘

       奇怪的慢sql 我们先来看2条sql 第一条: select * from acct_trans_log WHERE  acct_id = 1000000000009000757 order b ...

  6. ElasticSearch 学习记录之ES查询添加排序字段和使用missing或existing字段查询

    ES添加排序 在默认的情况下,ES 是根据文档的得分score来进行文档额排序的.但是自己可以根据自己的针对一些字段进行排序.就像下面的查询脚本一样.下面的这个查询是根据productid这个值进行排 ...

  7. hive:数据库“行专列”操作---使用collect_set/collect_list/collect_all & row_number()over(partition by 分组字段 [order by 排序字段])

    方案一:请参考<数据库“行专列”操作---使用row_number()over(partition by 分组字段 [order by 排序字段])>,该方案是sqlserver,orac ...

  8. c# ef 排序字段动态,构建动态Lambda和扩展方法OrderBy

    1.动态构建排序 Lambda /// <summary> /// 获取排序Lambda(如果动态排序,类型不同会导致转换失败) /// </summary> /// < ...

  9. 根据excel表格字段生成sql语句

    根据excel表格字段生成sql语句 1.1 前言 根据excel表格字段生成sql语句主要是利用了excel的拼接函数 CONCATENATE .该实例主要以mysql脚本支持.实例需求如下:exc ...

随机推荐

  1. Python自学:第三章 在列表末尾添加元素与在列表中插入元素

    motorcycles = ['honda', 'yamaha' ,'suzuki'] motorcycles.insert(0, "ducati") print(motorcyc ...

  2. 在虚拟环境下运行 Confluence 6

    这个页面针对运行在虚拟硬件环境下的 Confluence 提供一些信息. 概要 在虚拟环境(virtual machine (VM))下运行 Confluence 需要一些特定的技能来进行设定和进行管 ...

  3. Crisp String CodeForces - 1117F (状压)

    #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> ...

  4. HDU4609 计数问题+FFT

    题目大意: 给出n(1e5)条线段(长度为整数,<=1e5),求任取3条线段能组成一个三角形的概率. 用cnt[i]记录长度为i的线段的个数,通过卷积可以计算出两条线段长度之和为i的方案数sum ...

  5. 2018普及组摆渡车洛谷5017(dp做法)

    啦啦啦,这一篇是接上一篇的博客,上一篇是记忆化搜索,而这一篇是dp+前缀和小技巧 dp这种玄学做法我这种蒟蒻当然不是自己想出来的,参考https://blog.csdn.net/kkkksc03/ar ...

  6. Mysql服务配置优化

    mysql服务器优化包含 硬件优化.操作系统配置优化(cpu调度.网络.内存.虚拟内存.磁盘io).Mysql服务配置优化(最大连接数.表缓存等.存储引擎).表结构优化.索引优化 总共5个方面. 本片 ...

  7. 调用shutdown.sh后出现could not contact localhost8005 tomcat may not be running报错问题

    之前调用tomcat的shutdown.sh无法关闭tomcat,一直报could not contact localhost8005 tomcat may not be running错. 在网上找 ...

  8. Java语法基础学习DayEighteen(常用类)

    一.String类 1.特点 String代表不可变的字符序列,底层用char[]存放. String是final的. 2.内存解析 3.常用方法 int length() char charAt(i ...

  9. tail语法

    本文介绍Linux下tail命令的使用方法.linux tail命令用途是依照要求将指定的文件的最后部分输出到标准设备,通常是终端,通俗讲来,就是把某个档案文件的最后几行显示到终端上,假设该档案有更新 ...

  10. python 参数传递 传值还是传引用

    个人推测结论: 可变对象传引用,不可变对象传值 python里的变量不同于c中地址储值模型 a=100 b=100 print(id(a),id(b),a==b,a is b) #8790877986 ...