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的更多相关文章

  1. 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 ...

  2. jqGrid插件getCol方法的一个改进

    jgGrid插件是非常常用的一个基于jQuery的表格插件,功能非常强大.我最近也频繁使用.但是这个插件也有一些不够完善的地方.比如这个getCol方法. getCol方法接受三个参数 colname ...

  3. UVALive 6911---Double Swords(贪心+树状数组(或集合))

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  4. UVALive 6916---Punching Robot(卢卡斯+容斥)

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  5. 8-06循环结构WHILE

    WHILE 循环语句可以根据某些条件重复执行一条SQL语句或一个语句块. 语句: WHILE(条件) BEGIN 语句或语句块 END 程序调试: ALT+F5启动调试 F9切换断点  F10遂过程, ...

  6. php-sql-parser sql防注入脚本

    <?php /** * SQL Parser from: http://code.google.com/p/php-sql-parser/ * License: New BSD */ class ...

  7. 241. Different Ways to Add Parentheses

    241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...

  8. dojo/_base/lang源码分析

    dojo/_base/lang模块是一个工具模块,但几乎用dojo开发的app都会用到这个模块.模块中的方法能够在某些开发场景中避免繁冗的代码,接下来我们一起看看这些工具函数的使用和原理(仅仅是原理的 ...

  9. 2016暑假多校联合---Substring(后缀数组)

    2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...

随机推荐

  1. WAF绕过神器 (过安全狗、智创SQL注入)

    WAF绕过神器 (过安全狗.智创SQL注入) 发布时间:-- :10文章来源:网络文章作者:panni007 点击次数: 次 分享到: QQ空间 QQ微博 新浪微博 开心网 人人网 摘要:起因: by ...

  2. MYSQL索引失效的各种情形总结

    1) 没有查询条件,或者查询条件没有建立索引  2) 在查询条件上没有使用引导列  3) 查询的数量是大表的大部分,应该是30%以上.  4) 索引本身失效 5) 查询条件使用函数在索引列上,或者对索 ...

  3. Linux set env export declare unset

    http://www.it165.net/os/html/201405/8390.html env /etc/profile 环境变量 系统提供 可改 set /etc/bashrc及用户自定义的变量 ...

  4. CARP 使用笔记

    1.安装 freebsd 7.3下用kldload if_carp 加载不了,报找不到模块的错,升级到9.2后就可以了. 然后按照freebsd官方手册的ifconfig carp0 create创建 ...

  5. mysql导入和导出数据

    Linux下如何单个库进行导入和备份操作 1.将数据导入数据库mysql -u账号 -p密码 数据库<sql脚本 mysql -uroot -proot test</home/upload ...

  6. Android drawable的自动缩放

    今天在写程序时发现,一张图片被自动放大了,后来发现,这张图片放在了drawable-zh文件夹下,这个文件夹没有指定屏幕密度!于是将drawable-zh改为drawable-zh-nodpi,问题解 ...

  7. 菜单栏展开和收起效果(纯js)

    2014年6月25日 15:36:29 需要关注的是: 1.用cookie保存用户当前点击的菜单项,不打扰后端代码 2.通过数学计算得到要显示和隐藏的div 3.点击事件是动态绑定到a标签上的,因此当 ...

  8. [火狐REST] 火狐REST 模拟 HTTP get, post请求

  9. /bin/dd if=/path/to/source-file of=/path/to/backup-file

    [root@ok virhost]# qemu-img info 05t.img image: 05t.img file format: raw virtual size: 10G (10737418 ...

  10. 百度编辑器 ueditor .net开发

    ueditor1.4.3 下载地址:http://pan.baidu.com/s/1bnCQVtd   <!--editor--> <script type="text/j ...