I am working on some reporting code and I have found myself repeating a certain piece of code which contains a where and select cause over and over again? The only piece of information changing is the target field.
private static void UpdateResultsListInstructions(List<ManagementInfo> managementInfo, KeyValuePair<int, int> item)
{
managementInfo
.Where(m => m.YearMonthNo == item.Key)
.Select(m => m.VolumeOfInstructionsReceivedInMonth = item.Value)
.ToList();
}
private static void UpdateResultsListClaims(List<ManagementInfo> managementInfo, KeyValuePair<int, int> item)
{
managementInfo
.Where(m => m.YearMonthNo == item.Key)
.Select(m => m.VolumeOfClaimsCancelled = item.Value)
.ToList();
}
Is it possible to pass in the selector as an argument so I can reuse one method?
Along the lines of
UpdateCommonResultsList(managementInfo, item, (m => m.VolumeOfClaimsCancelled = item.Value))
I can probably rejig all the code so that this is not necessary but now that I've had the thought I'd like to see if its possible. Any help appreciated.