你能告诉我如何使用 LINQ 转换这个循环结构吗?
list<Entity> auditlist=retreivedata()\\method to fetch data
foreach (Entity obj in auditList)
obj.CultSpecificRevisedData = "NULL";
obj.CultSpecificPublishedData = "NULL";
if (obj.RevisedData != null && obj.RevisedData != "NULL")
obj.CultSpecificRevisedData = ConvertToProfileSpecificFormat(Convert.ToDecimal(obj.RevisedData), DecimalSeparator);
if (obj.PublishedData != null && obj.PublishedData != "NULL")
obj.CultSpecificPublishedData = ConvertToProfileSpecificFormat(Convert.ToDecimal(obj.PublishedData), DecimalSeparator);
var yearPart = obj.CalendarYear;
var monthPart = string.Empty;
var frequencyName = GetEnglishFrequencyBame(frequencyTypeMasId);
if (frequencyName == FrequencyType.Monthly)
{
monthPart = new DateTime(obj.CalendarYear, GetMonthNumber(obj.Month), 1).ToString("MMM");
obj.CultSpecificPeriod = monthPart + "-" + yearPart.ToString();
}
if (frequencyName == FrequencyType.Quarterly)
{
UserMessage = obj.QuarterName;
obj.CultSpecificPeriod = UserMessage + "-" + yearPart.ToString();
}
else if (frequencyName == FrequencyType.BiAnnually)
{
UserMessage = obj.SemesterName;
obj.CultSpecificPeriod = UserMessage + "-" + yearPart.ToString();
}
else
{
obj.CultSpecificPeriod = yearPart.ToString();
}
}