using System.Collections.Generic;
internal class EventWithDescription
public string EventKey { get; set; }
public override string ToString()
internal class EventPropertiesRepository
public bool TryGet(string eventKey, out TEvetProperties evetProperties)
internal class TEvetProperties
private static EventWithDescription Map(TEvetProperties eventProperties, EventWithDescription mappedEvent)
return new EventWithDescription {EventKey = string.Format("new key with {0}", mappedEvent.EventKey)};
private static IEnumerable<EventWithDescription> FillEventsProperties(EventWithDescription[] mappedEvents)
var eventPropertiesRepository = new EventPropertiesRepository();
var result = new List<EventWithDescription>();
foreach (var grouping in mappedEvents.GroupBy(x => x.EventKey))
TEvetProperties eventProperties = null;
if (eventPropertiesRepository.TryGet(grouping.Key, out eventProperties))
result.AddRange(grouping.Select(x => Map(eventProperties, x)));
public static void Main()
var eventWithDescriptions = new[]
new EventWithDescription {EventKey = "1"},
new EventWithDescription {EventKey = "1"},
new EventWithDescription {EventKey = "2"}
var newEvents = FillEventsProperties(eventWithDescriptions);
foreach(var newEvent in newEvents)
Console.WriteLine(newEvent);