我有以下型号:
public class HeadCount
{
public int Id { get; set; }
public int ContractId { get; set; }
public string FiscalYear { get; set; }
public string TaskOrder { get; set; }
public decimal ContractHours { get; set; }
public int PersonId { get; set; }
public string CompanyName { get; set; }
public string UserId { get; set; }
public int ClinAssignId { get; set; }
}
使用标准sql,我在SSMS中运行以下脚本:
select personid, sum(contracthours) as hours from headcounts where personid != 0 group by personid
我正在试图将其转换为LINQ menthod调用。这就是我试过的:
var results = _context.HeadCounts
.GroupBy(p => p.PersonId)
.Select(n => new {personid = n.Key, hours = n.Sum(ContractHours)});
它不喜欢Sum中的ContractHours
。我甚至试过n.ContractHours
我做错了什么?
答案 0 :(得分:1)
<coordinator-app name="${jobName}" frequency="${coord:days(1)}" start="${startTime}" end="${endTime}" timezone="${timezone}"
xmlns="uri:oozie:coordinator:0.2">
<controls>
<timeout>-1</timeout>
<concurrency>30</concurrency>
<execution>FIFO</execution>
</controls>
<datasets>
<dataset name="myData" frequency="${coord:days(1)}" initial-instance="${startTime}" timezone="UTC">
<uri-template>/time-independent/path/that/may/or/maynot/be/there</uri-template>
</dataset>
</datasets>
<input-events>
<data-in name="myInput" dataset="myData">
<instance>${startTime}</instance>
</data-in>
</input-events>
<action>
<workflow>
<app-path>${myAppPath}</app-path>
<configuration>
<property>
<name>myInput</name>
<value>${coord:dataIn('myInput')}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app>
会选择一个选择器,因此您需要:
Sum
答案 1 :(得分:0)
感谢Robs对原始问题的评论,这是我正在寻找的答案。