Hi!
I have sql code that returns all appointment times that are not used on certain date
select terminRez
from TerminRezervacije t
where not exists(select TerminRezervacijeID
from Rezervacija as r where
t.TerminRezervacijeID=r.TerminRezervacijeID and r.DatumRezervacije= '2021-01-14')
I managed to recreate it as query with c# LINQ
var termin = from t in db.TerminRezervacije
where !db.Rezervacija.Where(r => t.TerminRezervacijeID == r.TerminRezervacijeID
&& r.DatumRezervacije == mod.DatumRezervacije).Any()
select t.terminRez;
I want to be able to display available appointment times with dropdown list.
Right now i have setup with SelectListItem that loads all appointment times from db
and cant figure out how to implement this linq query to be able to display results of query in my SelectListItem dropdown list.
model.TerminRezervacije = db.TerminRezervacije
.Select(p => new SelectListItem
{
Value = p.TerminRezervacijeID.ToString(),
Text = p.terminRez
}).ToList();
I appreciate any help!!
What I have tried:
I recreated sql query in linq code but cant figure out how to add query results to dropdown list