BlueCollar.SQLiteRepository.GetScheduleDateExistsForSchedule C# (CSharp) Method

GetScheduleDateExistsForSchedule() public method

Gets a value indicating whether data exists for the given schedule ID and calculated schedule date. If it does, this indicates that jobs have already been enqueued for the schedule and should not be enqueued again until the next calculated schedule date.
public GetScheduleDateExistsForSchedule ( long scheduleId, System.DateTime scheduleDate, IDbTransaction transaction ) : bool
scheduleId long The ID of the schedule to check data for.
scheduleDate System.DateTime The calculated schedule date to check data for.
transaction IDbTransaction The transaction to use, if applicable.
return bool
        public bool GetScheduleDateExistsForSchedule(long scheduleId, DateTime scheduleDate, IDbTransaction transaction)
        {
            const string Sql = @"SELECT CAST(COUNT([Id]) AS bigint)
            FROM [BlueCollarHistory]
            WHERE
            [ScheduleId] = @ScheduleId
            AND datetime([QueuedOn]) = datetime(@ScheduleDate);

            SELECT CAST(COUNT([Id]) AS bigint)
            FROM [BlueCollarQueue]
            WHERE
            [ScheduleId] = @ScheduleId
            AND datetime([QueuedOn]) = datetime(@ScheduleDate);

            SELECT CAST(COUNT([Id]) AS bigint)
            FROM [BlueCollarWorking]
            WHERE
            [ScheduleId] = @ScheduleId
            AND datetime([QueuedOn]) = datetime(@ScheduleDate);";

            long count = 0;

            using (var multi = this.connection.QueryMultiple(Sql, new { ScheduleId = scheduleId, ScheduleDate = scheduleDate }, transaction, null, null))
            {
                count = multi.Read<long>().First()
                    + multi.Read<long>().First()
                    + multi.Read<long>().First();
            }

            return count > 0;
        }