这里我正在获取记录通过使用datetime.But我想那一天整个信息像总和
示例
ID Name Date Amount
1 Samsung 1/1/2016 3000
2 LG 1/1/2016 6000
3 Videocon 2/2/2015 200
4 Philips 2/2/2015 1500
5 Sony 3/5/2015 15000
如果我Select
约会与1/1/2016
约会,则应该完整Result
以及total --> 9000
&也称为Samsung-->3000
Lg--->6000
Total 9000
这里我有一些代码
public JsonResult Dif(int Date=0, int Month=0, int Year=0, int HH = 0, int MM = 0, int Ss = 0){
DateTime ss = new DateTime(Year, Month, Date, HH, MM, Ss);
var x = (from n in db.Employees where (n.DataofJoin == ss) select n);
return new JsonResult {Data=x, JsonRequestBehavior = JsonRequestBehavior.AllowGet };}
答案 0 :(得分:1)
试试这个:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('jshint-junit-reporter');
grunt.initConfig({
jshint: {
all: ['Gruntfile.js'],
reporter: require("jshint-junit-reporter"),
reporterOutput: "junit-output.xml"
}
});
};
编辑(感谢Mrinal更正): 您可以尝试以下语法:
var total = (from n in db.Employees where (n.DataofJoin == ss) select n.Amount).Sum();
答案 1 :(得分:0)
var total = db.Employees.Where(x=>x.Date == yourDate).Select(y=> y.Amount).Sum();
如果您希望每个日期收到手机型号的总数。
var result = db.Employees.Where(x=>x.Date == yourDate).
GroupBy(x=>x.Name, y=> y.Amount,
(x, y) => new { PhoneName = x, TotalAmount = y.Sum()).ToList();
这将返回每个特定日期的电话列表及其相关的总金额。