Nhibernate Case SUM
SELECT
ID
SUM(CASE WHEN myProperty = 2 THEN 1 ELSE 0 END) as nbRowWithValueOf2,
SUM(CASE WHEN myProperty = 3 THEN 1 ELSE 0 END) as nbRowWithValueOf3
FROM Foo
GROUP BY ID
queryover = queryover
.Select(
Projections.Group<Foo>(c => c.ID),
Projections.Sum(
Projections.Conditional(
Restrictions.Where<Foo>(f => f.myProperty == MyEnum.Two),
Projections.Constant(),
Projections.Constant())),
Projections.Sum(
Projections.Conditional(
Restrictions.Where<Foo>(f => f.myProperty == MyEnum.Three),
Projections.Constant(),
Projections.Constant())));
生成SQL
SELECT this_.ID as y0_,
sum((case
when this_.myProperty = 2 /* @p0 */ then 1 /* @p1 */
else 0 /* @p2 */
end)) as y1_,
sum((case
when this_.myProperty = 3 /* @p3 */ then 1 /* @p4 */
else 0 /* @p5 */
end)) as y2_
FROM [Foo] this_
GROUP BY this_.ID
Nhibernate Case SUM的更多相关文章
- LeetCode 560. Subarray Sum Equals K (子数组之和等于K)
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- jqGrid插件getCol方法的一个改进
jgGrid插件是非常常用的一个基于jQuery的表格插件,功能非常强大.我最近也频繁使用.但是这个插件也有一些不够完善的地方.比如这个getCol方法. getCol方法接受三个参数 colname ...
- UVALive 6911---Double Swords(贪心+树状数组(或集合))
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6916---Punching Robot(卢卡斯+容斥)
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- 8-06循环结构WHILE
WHILE 循环语句可以根据某些条件重复执行一条SQL语句或一个语句块. 语句: WHILE(条件) BEGIN 语句或语句块 END 程序调试: ALT+F5启动调试 F9切换断点 F10遂过程, ...
- php-sql-parser sql防注入脚本
<?php /** * SQL Parser from: http://code.google.com/p/php-sql-parser/ * License: New BSD */ class ...
- 241. Different Ways to Add Parentheses
241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...
- dojo/_base/lang源码分析
dojo/_base/lang模块是一个工具模块,但几乎用dojo开发的app都会用到这个模块.模块中的方法能够在某些开发场景中避免繁冗的代码,接下来我们一起看看这些工具函数的使用和原理(仅仅是原理的 ...
- 2016暑假多校联合---Substring(后缀数组)
2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...
随机推荐
- systemd在各个linux发行版的普及
后面我要说下自己的意见: 原则如果阻碍了进步,那还算个屁,不客气地说,UNIX 原则已经过时了. 移植性问题:我除了 Mac 外不用任何 BSD 系统,当然 Mac 上一般只做开发不做运维(但就算如此 ...
- JQuery $.ajax()方法详解
jQuery Ajax 参考手册 实例 通过 AJAX 加载一段文本: jQuery 代码: $(document).ready(function(){ $("#b01").cli ...
- 六间房 去掉水印的方法 绕过游客VIP限制
firefox 40 + Adblock Plus 2.6.9.1 + Execute JS 0.2.4.1 Adblock Plus 过滤规则里添加 ------------------------ ...
- mybatis整合spring 之 基于接口映射的多对一关系
转载自:http://my.oschina.net/huangcongmin12/blog/83731 mybatis整合spring 之 基于接口映射的多对一关系. 项目用到俩个表,即studen ...
- Eclipse调试:F5、F6、F7、F8
F5:跳入方法 F6:向下逐行调试 F7:跳出方法 F8:直接跳转到下一个断点 转载自:http://blog.sina.com.cn/s/blog_6271df6f0101d856.html
- extjs插件开发上传下载文件简单案例
前台,extjs,框架,mybatis,spring,springMVC,简单的文件上传下载案例. 必要的jar包,commons-fileupload-1.3.1.jar,commons-io-2. ...
- php请求URL中的参数有空格
url=http://www.123.com/abc.php?name=ku xiong ku xiong之间有一个空格,需要替换成%20或者+ url=http://www.123.com/abc. ...
- wait() 与 sleep
1.对于两种方法区别 1. 这两个方法来自不同的类,sleep方法属于Thread,wait方法属于Object. 2. 最主要是sleep方法没有释放锁,而wait方法释放了锁,使得其他线程可以使用 ...
- w
w --help -f 开启或关闭显示用户从何处登入系统. -h 不显示各栏位的标题信息列. -l 使用详细格式列表,此为预设值. -s 使用简洁格式列表,不显示用户登入时间,终端机阶段作业和程序所耗 ...
- ajax 中文乱码问题 主要是IE浏览器
解决方案: 提交前采用encodeURI两次编码,注:一定是两次 举例: var taText = $("#txtName").val(); taText = encodeURI( ...