public static IEnumerable<JobLocationReference> JobLocationReferences(this IEnumerable<JobTableStatusItemModel> Items) { return Items.Where(i => !string.IsNullOrWhiteSpace(i.DeviceHeldLocation) && i.DeviceHeld.HasValue && !i.DeviceReturnedDate.HasValue) .GroupBy(i => i.DeviceHeldLocation, StringComparer.OrdinalIgnoreCase) .Select(i => new JobLocationReference() { Location = i.Key, References = i.ToList() }); } }