如何使用ms sql从[Code]列中获取[Result]列
Id Code
200001 43791
200001 67036
200006 19.09.01.08683
200006 03.01.04.01.64230
200007 19.01.03.02804
Id Result Code
200001 43791 43791
200001 67036 67036
200006 08683 19.09.01.08683
200006 64230 03.01.04.01.64230
200007 02804 19.01.03.02804
Run Code Online (Sandbox Code Playgroud) 我有以下动态列表
Crew NameSurname Period Result
ABC John DOE Q1 54,09
ABC John DOE Q2 59,57
ABC John DOE Q3 62,11
Run Code Online (Sandbox Code Playgroud)
如何在linq中获得此结果.
Crew NameSurname Q1 Q2 Q3
ABC John DOE 47,51 47,51 51,46
Run Code Online (Sandbox Code Playgroud)
我试过这种方式,但我无法得到结果
List.GroupBy(c => c.PersonnelID)
.Select(g => new
{
PersonnelID = g.Key,
Period1 = g.Where(c => c.Period == 1).Sum(c => c.Result),
Period2 = g.Where(c => c.Period == 2).Sum(c => c.Result),
Period3 = g.Where(c => c.Period == 3).Sum(c => c.Result)
});
Run Code Online (Sandbox Code Playgroud) 我有非常相似的管道作业,唯一的区别是参数。目标是通过在 DSL 脚本中传递参数来创建这些作业,而无需任何代码重复。
我关注了这篇文章。因此,如果您在执行本文中提到的步骤后运行下面的 DSL 脚本,我的脚本就可以运行。
TL;DR 在那篇文章中添加了一个共享库,并且让 Jenkinsfile 使用该共享库。
我有一个非常相似的方法。不同之处在于我想通过 DSL 创建构建作业,并通过 DSL 上的设置更改 Jenkinsfile 的默认参数。
问题是如何传递/覆盖 Jenkinsfile 中的参数。
// BTW I'll run this code below in a loop. Open for any suggesstion
pipelineJob('AwesomeBild') {
description("A pipeline created by dsl")
definition {
cpsScm {
scm {
git {
remote { url('https://github.com/jalogut/jenkinsfile-shared-library-sample.git') }
branches('master')
// how can I pass params to the file
scriptPath('Jenkinsfile')
extensions { }
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
编辑
参数效果良好。这是 DSL 文件的最新版本。
pipelineJob('AwesomeBild') { …Run Code Online (Sandbox Code Playgroud)