我试图循环通过一个 IEnumerable 但由于某种原因它没有通过 foreach 循环,因为每个 ChartClass 的值都没有被修改。
public IEnumerable<ChartClass> get(string ID, string buildname, string placeholder)
{
var context = new Entities();
var metrics = from c in context.VSTS_CODE_METRICS
where c.BUILD_NAME == buildname && c.OBJECT_TYPE == "Namespace"
group c by c.BUILD_ID into g
select new ChartClass
{
Build_ID = g.Key,
BuildTrim = g.Key,
Index = g.Average(c => c.MAINTAINABILITYINDEX_).Value
};
foreach (var i in metrics)
{
int num = i.BuildTrim.LastIndexOf('_');
i.BuildTrim = "2";
}
return metrics;
}
我正在尝试将每个 ChartClass 的 BuildTrim 字段更改为“2”,但由于某种原因没有发生