oData 排序字段生成
跟踪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 排序字段生成的更多相关文章
- Woocommerce 分类下的产品如何使用ID号来作为默认排序字段
在给一个客户开发网店系统时使用了WordPress系统的Woocommerce插件 WordPress版本:3.8 Woocommerce版本:2.0.20 如果没有指定排序规则(指定的字段),则Wo ...
- sql 分组后查询出排序字段
select row_number() over(partition by CODE order by SEQUENCE) as RowIndex from Table 注:根据表的CODE 字 ...
- 去重 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN
关键字 ROW_NUMBER() OVER(PARTITION BY 分组字段 ORDER BY 排序字段) RN 按照分组字段进行排序并标编号 ROW_NUMBER() OVER(PARTITIO ...
- EntityFramework动态组合多排序字段
前言:在使用EF当中,肯定会遇到动态查询的需求,建立一个公共调用的动态组合表达式查询也是必不可少的,以下是建立动态组合多排序字段做个记录,供以后调用 1.建立一个结构,用于多个排序字段组合,这个结构体 ...
- sql查询调优之where条件排序字段以及limit使用索引的奥秘
奇怪的慢sql 我们先来看2条sql 第一条: select * from acct_trans_log WHERE acct_id = 1000000000009000757 order b ...
- ElasticSearch 学习记录之ES查询添加排序字段和使用missing或existing字段查询
ES添加排序 在默认的情况下,ES 是根据文档的得分score来进行文档额排序的.但是自己可以根据自己的针对一些字段进行排序.就像下面的查询脚本一样.下面的这个查询是根据productid这个值进行排 ...
- hive:数据库“行专列”操作---使用collect_set/collect_list/collect_all & row_number()over(partition by 分组字段 [order by 排序字段])
方案一:请参考<数据库“行专列”操作---使用row_number()over(partition by 分组字段 [order by 排序字段])>,该方案是sqlserver,orac ...
- c# ef 排序字段动态,构建动态Lambda和扩展方法OrderBy
1.动态构建排序 Lambda /// <summary> /// 获取排序Lambda(如果动态排序,类型不同会导致转换失败) /// </summary> /// < ...
- 根据excel表格字段生成sql语句
根据excel表格字段生成sql语句 1.1 前言 根据excel表格字段生成sql语句主要是利用了excel的拼接函数 CONCATENATE .该实例主要以mysql脚本支持.实例需求如下:exc ...
随机推荐
- MySql 8.0 版本使用navicat连不上解决
先通过命令行进入mysql的root账户: 更改加密方式 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE ...
- Php的基本语法学习
1.php语法 当 PHP 解析一个文件时,会寻找开始和结束标记,标记告诉 PHP 开始和停止解释其中的代码. 1)标记语法 是以<?php 开头,?> 结束,相当于html标签的开始标签 ...
- 序列化模块— json模块,pickle模块,shelve模块
json模块 pickle模块 shelve模块 序列化——将原本的字典.列表等内容转换成一个字符串的过程就叫做序列化. # 序列化模块 # 数据类型转化成字符串的过程就是序列化 # 为了方便存储和网 ...
- 指导手册05:MapReduce编程入门
指导手册05:MapReduce编程入门 Part 1:使用Eclipse创建MapReduce工程 操作系统: Centos 6.8, hadoop 2.6.4 情景描述: 因为Hadoop本身 ...
- windows下telnet不是内部或外部命令
选择“程序和功能” 设置完后
- Java容器解析系列(5) AbstractSequentialList LinkedList 详解
AbstractSequentialList为顺序访问的list提供了一个骨架实现,使实现顺序访问的list变得简单; 我们来看源码: /** AbstractSequentialList 继承自 A ...
- Java语法基础学习DayThirteen(枚举类和注解)
一.枚举类 1.概述:即一个类中只能有有限个对象,若只有一个对象,则可以作为单例模式的一种实现. 2.自定义枚举类(JDK1.5以前这么做) //枚举类 class Season{ //1.提供类的属 ...
- linux之文件增删改查
- 入门项目 A1 start
''' 启动文件入口 ''' from core import src import os import sys # 拿到项目的路径 path = os.path.dirname(__file__) ...
- python day21 ——面向对像-反射 getattr,内置方法
一.反射:用字符串数据类型的变量名来访问这个变量的值 上代码^_^ # class Student: # ROLE = 'STUDENT' # @classmethod # def check_cou ...