TrainNotifier.Service.TrainMovementRepository.GetMatchingSchedules C# (CSharp) Method

GetMatchingSchedules() private method

this will pick up cancelled schedules which dont have any stops
private GetMatchingSchedules ( IEnumerable schedules, System.DateTime date, string atocCode, PowerType powerType ) : IEnumerable
schedules IEnumerable
date System.DateTime
atocCode string
powerType PowerType
return IEnumerable
        private IEnumerable<ScheduleHolder> GetMatchingSchedules(IEnumerable<ScheduleHolder> schedules, DateTime date, string atocCode, PowerType? powerType)
        {
            if (!schedules.Any())
                return Enumerable.Empty<ScheduleHolder>();

            const string sql = @"
                SELECT [ScheduleTrain].[ScheduleId]
                    ,[ScheduleTrain].[TrainUid]
                    ,[ScheduleTrain].[STPIndicatorId]
                    FROM [ScheduleTrain]
                    WHERE
                        [TrainUid] IN @trainUids
                        AND @date >= [StartDate]
                        AND @date <= [EndDate]
                        AND [Deleted] = 0
                        AND [Runs{0}] = 1{1}{2}
                    ORDER BY [STPIndicatorId]";

            return Query<ScheduleHolder>(string.Format(sql,
                date.DayOfWeek,
                (!string.IsNullOrEmpty(atocCode) ? _atocCodeFilter : string.Empty),
                (powerType.HasValue ? _powerTypeFilter : string.Empty)), new
                {
                    trainUids = schedules.Select(t => t.TrainUid).Distinct(),
                    date = date.Date,
                    atocCode,
                    powerType
                });
        }