查询考勤数据,每个人每天的考勤数据可能有多条,考勤统计查询时,需要展现某个时间段内(比如一个月)所有人的考勤时间,
表名:AttendanceInfo
字段:userName用户名
userCard员工编号
ClockTime 打卡时间
用Linq 查出某个时间段内,所有人每天的考勤时间,即每天的最早打卡时间和最晚打卡时间。
static List<User> list = new List<User>()
{
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-26 9:00:00")},
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-26 10:00:00")},
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-26 15:00:00")},
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-27 8:00:00")},
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-27 9:00:00")},
new User(){id=1,name="Jay",cardTime=DateTime.Parse("2017-04-27 12:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-26 9:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-26 22:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-26 23:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-27 9:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-28 9:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-28 10:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-28 11:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-29 9:00:00")},
new User(){id=2,name="h12",cardTime=DateTime.Parse("2017-04-29 21:00:00")},
};
static void Main(string[] args)
{
//每人,每天最早最晚的记录
var o = list.GroupBy(x => new { x.id, x.cardTime.Date }).Select(g => new { g, count = g.Count() })
.SelectMany(t => t.g.Select((b, i) => new { b, i,t.count })).Where(x=>x.i==0 || x.i==(x.count-1));
foreach (var item in o)
{
Console.WriteLine("{0} {1} {2}", item.b.id, item.b.name, item.b.cardTime);
}
Console.ReadLine();
}
var q = users.GroupBy(d => new { d.name, d.cardTime.Date }).
Select(d => new
{
名字 = d.Key.name,
日期 = d.Key.Date.ToString("yyyy-MM-dd"),
最早 = users.FirstOrDefault(x => x.name == d.Key.name && x.cardTime.Date == d.Key.Date.Date).cardTime,
最晚 = users.LastOrDefault(x => x.name == d.Key.name && x.cardTime.Date == d.Key.Date.Date).cardTime
}).ToList();
q.ForEach(item => {
Console.WriteLine(item.ToJson());
});
{"名字":"Jay","日期":"2017-04-26","最早":"2017-04-26T09:00:00","最晚":"2017-04-26T15:00:00"}
{"名字":"Jay","日期":"2017-04-27","最早":"2017-04-27T08:00:00","最晚":"2017-04-27T12:00:00"}
{"名字":"h12","日期":"2017-04-26","最早":"2017-04-26T09:00:00","最晚":"2017-04-26T23:00:00"}
{"名字":"h12","日期":"2017-04-27","最早":"2017-04-27T09:00:00","最晚":"2017-04-27T09:00:00"}
{"名字":"h12","日期":"2017-04-28","最早":"2017-04-28T09:00:00","最晚":"2017-04-28T11:00:00"}
{"名字":"h12","日期":"2017-04-29","最早":"2017-04-29T09:00:00","最晚":"2017-04-29T21:00:00"}
public class User
{
public virtual int id { get; set; }
public virtual string name { get; set; }
public virtual DateTime cardTime { get; set; }
}
最近在做考勤系统时,由于不同的分公司的数据源在不同的服务器上,关联查询比较麻烦,因此想到了用Linq实现关联查询。 思路:查询各个考勤信息的dataTable,然后用Linq实现DataTable的多张表左关联查询。贴出来,与...
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;...using System.Linq; using System.Text; using System.Thr...
Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;...using System.Drawing;...using System.Linq; using System.Text; using System.Threading.Tasks;
Linq实现LEFT OUT JOIN 原文地址:http://geekswithblogs.net/AzamSharp/archive/2008/04/07/121103.aspx Suppose you have a tblRoom and tblUserInfo. Now, you need to select all the rooms regardless of ...
Suppose you have a tblRoom and tblUserInfo. Now, you need to select all the rooms regardless of whether the room has user information or not. This calls for a LEFT JOIN which will select everything
using System.Collections.Generic; using UnityEngine;...using Newtonsoft.Json.Linq; using UnityEngine.UI; using System.IO; //识别,(用于签到考勤) public class FaceIdentify : MonoBehaviour {...
由于公司实施SAP HR项目,但是SAP HR对考勤功能真的太弱化了,直接从考勤机上读取的原始打卡记录不能直接传输到HR系统里面,因为SAP HR不能识别那些多余的打卡记录,而且必须把打卡记录进行成组标记(P10,P20),以上...
http://blog.csdn.net/make1828/article/details/16343103 Suppose you have a tblRoom and tblUserInfo. Now, you need to select all the rooms regardless of whether the room has user information or not
ASP.NET MVC Linq 技术 企业级通用OA系统 全程开发 大型企业级别OA项目实战全新上线啦!本项目由小孔子讲师全程录制。小孔子老师大家都很熟悉了,他所录制的其他课程都受到了学员的一致好评!小...
本系统开发环境为Visual Studio 2010,使用.net 4.0开发,使用AForge库和Aipsdk库和Newtonsoft.json库和system.sqlite库以及第三方插件DevExpress完成。 本系统特点:分为人脸库的录入,将信息保存在sqlite数据库中...
对这个课程有兴趣的朋友可以加我的qq2059055336和我联系哦 ...小孔子拥有多年Web开发经验和讲师培训经验,极擅长Asp、Asp.net开发,也是VB、C#语言方面的资深专家,同时精通Js、Div+Css、Ajax、Asp.net MVC、Linq
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;...using System.Linq; using System.Text; using System.Windows.Forms; namespace myDgv
本次开发主要做了从串口分别获取读者卡号和图书卡号,实现图书管理,图书借阅,读者管理等功能。开发语言是C#,开发环境使用Visual Studio 2015。数据库采用sql Server。
我这里有套课程想和大家分享,需要的朋友可以加我qq和我联系。QQ2059055336.<wbr><wbr></wbr></wbr> <wbr>...北风的口
using System; using System.Collections.Generic;...using System.Linq; using System.Text; using System.Threading.Tasks; using OtherNamespce; namespace CurrentNamespace { class Program...
部分代码: Default页布局一个Calendar日期控件 ? 1 2 3 4 5 div> asp:Calendar ID="Calendar1" runat="server" Width="100%" ...ondayrender="Calendar1_DayRende
刷卡客户端实现 客户端界面效果图: 2.客户端功能实现 一:窗体代码 1 namespace WriteCard 2 { 3 partial class FrmCard 4 { 5 /// <summary> 6 /// 必需的设计器变量。 7 /// <....
<img data-cke-saved-src="...
数据库菜单表: SQL脚本: 1 use master 2 go 3 4 create database TreeViewDemo 5 on primary 6 ( 7 name='TreeViewDemo_data', ... 8 filename='C:\2Study\SQLServer\TreeViewDemo\TreeViewD...
一、背景介绍 我们日常开发网站时,经常会用到下图这样的下拉框。...如果在项目中引入Redis这一类缓存框架,好像又不太划算,所以我们可以选择自己实现一个简单的缓存 这篇文章的目的不是具体的介绍设...
在涉及到获取第三方数据的时候都会涉及到调用接口,小编为此也是搜索了很长一段时间呢!...using System; using System.Collections.Generic; using System.IO; using Sys...
包括3个大项目和若干衍生项目,涵盖:数码相框、电子书、指针、链表、Makefile、网络编程Socket、USB摄像头、CMOS摄像头、视频监控、WIFI、3G网卡、ALSA声卡、便携式视频监控(
这不是rtos源码分析的课程,而是为初级的同学设计,从基础原理讲师,一步步不断迭代设计rtos的课程! 用不到【2000行代码,汇编代码仅18行】(不含注释)实现一个精巧的可以运行在ARM Cortex-M内核芯片上
文档内包含pr2019版本的破解版,只需在解压后点击Setup.exe即可一键安装。
Problem C: 电商里的数据财富 在电商市场中,亚马逊为消费者提供了对购买商品的评价(打分和评论)的服务。个人评级,又称为“星级评级”,意思是允许消费者使用1(低分差评,低满意度)到5(高分好评,高满意度)的等级来表达他们对产品的满意度。此外,消费者可以提交基于文本的信息,“评论”——表示对产品的进一步意见和信息。其他顾客可以在这些评论上打分,判断评论是否对他们有帮助,这又被称为“有用评分”,以帮助他们决定产品的购买决策。公司利用这些数据来洞察他们所参与的市场、参与的时机以及产品设计特性选择的潜在商机。
董付国老师系列教材《Python程序设计基础》(ISBN:9787302410584)、《Python程序设计(第2版)》(ISBN:9787302436515)、《Python可以这样学》(ISBN:9787302456469)配套视频,通过大量实际案例讲解Pyth
2019美赛题目,完全是从官网下载,无翻译,可使用有道软件翻译浏览
讲诉python爬虫的20个案例 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
本仓库发布的jd_seckill项目中涉及的任何脚本,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。 本项目内所有资源文件,禁止任何公众号、自媒体进行任何形式的转载、发布。 huanghyw 对任何脚本问题概不负责,包括但不限于由任何脚本错误导致的任何损失或损害. 间接使用脚本的任何用户,包括但不限于建立VPS或在某些行为违反国家/地区法律或相关法规的情况下进行传播, huanghyw 对于由此引起的任何隐私泄漏或其他后果概不负责。 请勿将jd_seckill项目的任何内容用于商业或非法目的,否则后果自负。
本课程主要讲解如下内容:Oracle体系结构、Oracle 基础管理、SQL 语言、Sequence和同义词、数据字典及用户管理、E-R模型、Power Designer设计工具。在本