I have a razor page with a select tag:
<select asp-for="Curriculum" asp-items="Model.Curricula"></select>
In my page model I can populate the values using EF and LINQ:
public List<SelectListItem> Curricula => (from cur in _db.Curriculum
join c in _db.Courses on cur.CurriculumID equals c.CurriculumID
into temp
from q in temp.DefaultIfEmpty()
where cur.CurriculumStatusID == 1 && !(q.OnDemand == true)
orderby cur.Curriculum
select new SelectListItem { Value = cur.CurriculumID.ToString(), Text = cur.Curriculum }
).ToList();
This works but two things I want to change are:
I'd like to use Dapper instead of the long LINQ statement
I'd like to put the SQL Query in my Service layer instead of in my UI layer
Any suggestions for how to do this?