将LINQ中的值传递给Call方法
本文关键字:Call 方法 值传 LINQ | 更新日期: 2023-09-27 18:16:44
我的代码中有以下方法。我想从LINQ中调用这个方法。我该怎么做呢?我想过不同的时间,像每年,每月,每周,每天
private Time DecideMinTime(IEnumerable<Time> g) { }
这是我试图调用这个方法的LINQ
var exportRuns =
this.exportInformationRepository.GetAll()
.GroupBy(ei => new { ei.StartDate, ei.StudyIdentifier })
.Select(
g =>
new ExportRun()
{
ExportInformations = g,
MinimumTimeGranularity = DecideMinTime(), //Call the method
StartDate = g.Key.StartDate,
StudyIdentifier = g.Key.StudyIdentifier
});
return exportRuns;
方法中传递给IEnumerable的内容
我将假设您正在分组的对象具有Time
类型的某些属性。如果我们假设它叫做Foo
那么你可以这样做:
MinimumTimeGranularity = DecideMinTime(g.Select(i => i.Foo)),