public static IEnumerable <LogRowKey> FindClosestTriggerKeys(this IItemDatabase db, long sourceUniqueId, long sourceCycleIndex, IEnumerable <string> triggerIds) { var triggerWithUniqueIds = triggerIds.Select(p => new { ItemId = p, UniqueIds = db.GetLogRowUniqueID(p) }); foreach (var triggerWithUniqueId in triggerWithUniqueIds) { yield return(db.FindClosestRowKey(sourceUniqueId, sourceCycleIndex, triggerWithUniqueId.ItemId, triggerWithUniqueId.UniqueIds)); } }