EF Groupby
最近做了个检索类的项目,其中就用到统计了,就是按照热门搜索排序来的。
话不多说,直接代码
var requirementSearchesOrder = app_RequirementSearches.GroupBy(EF => EF.Content).OrderByDescending(EF => EF.Count());
很简单,就是利用ef的分组查询,然后按照分组后的总和进行排序。
那么迭代这个集合,实际上就是在迭代这个分组后的key
foreach (var item in requirementSearchesOrder)
{
var x = item.Count();
hotSearchs.Add(item.Key);
}
这里的x就是这个分组元素的数量。key就是分组出来的元素
EF Groupby的更多相关文章
- EF GroupBy 根据key 分组 再把key求和(取决于每条数据中 arr的条数) arr 中有多少条数据 就把多少个key 加起来
List<A> alist = new List<A>{ ,b=,c=,d=,e=}, ,b=,c=,d=,e=}, ,b=,c=,d=,e=}, ,b=,c=,d=,e=}, ...
- EF GroupBy 分组 取某条的 总数
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 工作总结 EF GroupBy() Select() Select() 中 Count() 分组 求总
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- mvc学习(二)
1.后台foreach 与 html的关系 <table border="1">@for (var i = 0; i < 10; i++){@Html.Raw(i ...
- %E3%80%90%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B%E3%80%91
"%3Cdiv%20class%3D%22htmledit_views%22%20id%3D%22content_views%22%3E%0A%20%20%20%20%20%20%20%20 ...
- EF 求和 GroupBy多个字段
GroupBy根据多个字段分组使用方式: 一.使用扩展方法 query.GroupBy(q => new { q.Year, q.Month }) .Select(q => new { Y ...
- EF中GroupBy扩展方法的简单使用
public ActionResult ShopInfo() { ViewBag.ShopList = ShopService.GetEntities(x => x.IsDelete == fa ...
- Ef数据GroupBy多字段查询Vb.net与c#参考
Dim g = lst.Data.GroupBy(Function(T) New With { Key T.mName, Key T.mUnit, Key T.mPrice }).Select(Fun ...
- EntityFramework Core技术线路(EF7已经更名为EF Core,并于2016年6月底发布)
官方文档英文地址:https://github.com/aspnet/EntityFramework/wiki/Roadmap 历经延期和更名,新版本的实体框架终于要和大家见面了,虽然还有点害羞.请大 ...
随机推荐
- Codeforces Round #341 (Div. 2)B
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Spring框架介绍和原理
SpringMVC框架介绍 1) Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面. Spring 框架提供了构建 Web 应用程序的全功 ...
- Spring 容器AOP的实现原理——动态代理
参考:http://wiki.jikexueyuan.com/project/ssh-noob-learning/dynamic-proxy.html(from极客学院) 一.介绍 Spring的动态 ...
- 分别利用并查集,DFS和BFS方法求联通块的数量
联通块是指给定n个点,输入a,b(1<=a,b<=n),然后将a,b连接,凡是连接在一起的所有数就是一个联通块: 题意:第一行输入n,m,分别表示有n个数,有输入m对连接点,以下将要输入m ...
- MongoDB入门(3)- MongoDB备份与恢复
1. 备份 MongoDB提供了备份工具,mongodump.exe,在bin目录下,其用法如下: mongodump.exe -h localhost -d database_name -o d:\ ...
- python测试rabbitmq简易实例
生产者 import pika #coding=utf8 credentials = pika.PlainCredentials('guest', '密码') connection = pika.Bl ...
- 4 Values whose Sum is 0 POJ 2785 (折半枚举)
题目链接 Description The SUM problem can be formulated as follows: given four lists A, B, C, D of intege ...
- java 连接数据库报错:Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '
1.解决方法: 报错信息为: Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server ti ...
- mysql中的单引号/小数点/字符转换为数字/警告信息
我们准备玩点有趣的: select 一个数字: mysql from mysql.user; +---+ | +---+ | | | +---+ rows in set (0.00 sec) mysq ...
- 大原則 研讀 spec 與 code 的 心得
最近在研究 stm32f429i-disc0 的 device tree source code, 並且 參造 Devicetree Specification Release 0.1, 在 dts ...