var data = new[]
{
new Test { Date = DateTime.Now, Code = ActionCode.Value52 },
new Test { Date = DateTime.Now, Code = ActionCode.Value53 },
new Test { Date = DateTime.Now, Code = ActionCode.Value54 },
new Test { Date = DateTime.Now, Code = ActionCode.Value54 },
new Test { Date = DateTime.Now, Code = ActionCode.Value55 },
new Test { Date = DateTime.Now, Code = ActionCode.Value56 },
new Test { Date = DateTime.Now, Code = ActionCode.Value52 },
new Test { Date = DateTime.Now, Code = ActionCode.Value52 },
new Test { Date = DateTime.Now, Code = ActionCode.Value52 },
new Test { Date = DateTime.Now, Code = ActionCode.Value53 },
new Test { Date = DateTime.Now, Code = ActionCode.Value54 },
new Test { Date = DateTime.Now, Code = ActionCode.Value55 },
new Test { Date = DateTime.Now, Code = ActionCode.Value55 },
new Test { Date = DateTime.Now, Code = ActionCode.Value55 },
new Test { Date = DateTime.Now, Code = ActionCode.Value56 },
new Test { Date = DateTime.Now, Code = ActionCode.Value56 },
new Test { Date = DateTime.Now, Code = ActionCode.Value56 }
};
//Вариант 1
var result = data.GroupBy(x => x.Code).Select(x => new { Code = x.Key, Values = x.Key == ActionCode.Value52 ? new[] { x.First() }.AsEnumerable() : x }).ToList();
//Вариант 2
var result2_1 = data.Where(x => x.Code == ActionCode.Value52);
var result2_2 = data.Where(x => x.Code != ActionCode.Value52).GroupBy(x => x.Code).Select(x => x.First());
//result2_1 и result2_2 можно объединить в одну коллекцию и работать дальше с одной коллекцией
class Test
{
public DateTime Date { get; set; }
public ActionCode Code { get; set; }
public override string ToString()
{
return $"{Code} - {Date}";
}
}
public enum ActionCode
{
Value52,
Value53,
Value54,
Value55,
Value56
}