public static IEnumerable <CsvCourseRow> FromModel(Course row, IReadOnlyCollection <Region> allRegions) =>
 row.CourseRuns
 .OrderBy(x => x.StartDate)
 .ThenBy(x => x.DeliveryMode)
 .Select(courseRun => new CsvCourseRow()
 {
     LearnAimRef            = row.LearnAimRef,
     WhoThisCourseIsFor     = row.CourseDescription,
     EntryRequirements      = row.EntryRequirements,
     WhatYouWillLearn       = row.WhatYoullLearn,
     HowYouWillLearn        = row.HowYoullLearn,
     WhatYouWillNeedToBring = row.WhatYoullNeed,
     HowYouWillBeAssessed   = row.HowYoullBeAssessed,
     WhereNext         = row.WhereNext,
     CourseName        = courseRun.CourseName,
     ProviderCourseRef = courseRun.ProviderCourseId,
     DeliveryMode      = ParsedCsvCourseRow.MapDeliveryMode(courseRun.DeliveryMode),
     StartDate         = ParsedCsvCourseRow.MapStartDate(courseRun.StartDate),
     FlexibleStartDate = ParsedCsvCourseRow.MapFlexibleStartDate(courseRun.FlexibleStartDate),
     VenueName         = courseRun.VenueName,
     ProviderVenueRef  = courseRun.ProviderVenueRef,
     NationalDelivery  = ParsedCsvCourseRow.MapNationalDelivery(courseRun.National),
     SubRegions        = ParsedCsvCourseRow.MapSubRegions(courseRun.SubRegionIds, allRegions),
     CourseWebPage     = courseRun.CourseWebsite,
     Cost              = ParsedCsvCourseRow.MapCost(courseRun.Cost),
     CostDescription   = courseRun.CostDescription,
     Duration          = ParsedCsvCourseRow.MapDuration(courseRun.DurationValue),
     DurationUnit      = ParsedCsvCourseRow.MapDurationUnit(courseRun.DurationUnit),
     StudyMode         = ParsedCsvCourseRow.MapStudyMode(courseRun.StudyMode) ?? "",
     AttendancePattern = ParsedCsvCourseRow.MapAttendancePattern(courseRun.AttendancePattern) ?? ""
 });
 static async IAsyncEnumerable <Csv> Process(IAsyncEnumerable <LiveCoursesWithRegionsAndVenuesReportItem> results)
 {
     await foreach (var result in results)
     {
         yield return(new Csv
         {
             ProviderUkprn = result.ProviderUkprn.ToString(),
             CourseId = result.CourseId.ToString(),
             CourseRunId = result.CourseRunId.ToString(),
             CourseName = result.CourseName,
             CourseDescription = result.CourseDescription,
             CourseUrl = result.CourseWebsite,
             LarsId = result.LearnAimRef,
             DeliveryMode = result.DeliveryMode,
             AttendancePattern = result.AttendancePattern,
             StudyMode = result.StudyMode,
             IsFlexible = result.FlexibleStartDate,
             StartDate = ParsedCsvCourseRow.MapStartDate(result.StartDate),
             DurationUnit = result.DurationUnit,
             DurationValue = result.DurationValue,
             Cost = ParsedCsvCourseRow.MapCost(result.Cost),
             CostDescription = result.CostDescription,
             IsNational = result.National,
             Regions = result.Regions,
             LocationName = result.VenueName,
             LocationAddress1 = result.VenueAddress1,
             LocationAddress2 = result.VenueAddress2,
             LocationCounty = result.VenueCounty,
             LocationEmail = result.VenueEmail,
             LocationLat = result.VenueLatitude,
             LocationLon = result.VenueLongitude,
             LocationPostcode = result.VenuePostcode,
             LocationTown = result.VenueTown,
             LocationPhone = result.VenueTelephone,
             LocationWebsite = result.VenueWebsite,
             UpdatedDate = ParsedCsvCourseRow.MapStartDate(result.UpdatedOn),
             EntryRequirements = result.EntryRequirements,
             HowYouWillBeAssessed = result.HowYouWillBeAssessed
         });
     }
 }