我需要重构此代码,以便数据服务不会查询每个行项的两个工作类型。提前致谢。
_attributeGroups = attributeGroups.Select(attributeGroupRowModel =>
new AttributeGroupRowModel()
{
Name = attributeGroupRowModel.Name,
WorkType = workTypes.First(wt => wt.Id == attributeGroupRowModel.WorkTypeId).Description,
IsExpired = workTypes.First(wt => wt.Id == attributeGroupRowModel.WorkTypeId).IsExpired, //todo: not efficient, to be refactored
}).ToList();