I realized that for some odd reason you can’t chain the .Where() after the .Select(), so I came up with this.
var eventCalendar = db.EventCalendars.Where(q => q.Date == e.Day.Date);
if (!isLogged)
{
eventCalendar = eventCalendar.Where(q => q.ClientFlag == true);
}
eventCalendar = eventCalendar.Select(q => q.EnvironmentId).Distinct();
but now I get and error at the .Select
"Cannot implicitly convert type 'System.Linq.IQueryable<short>' to 'System.Linq.IQueryable<IT_Portal.EventCalendar>'. An explicit conversion exists (are you missing a cast?)"
What am I doing wrong? To put it simply, I just want to be able to grab Distinct Environment ID from the Calendar Event table so that I can notify users if there is an event occurring that day on a specific environment. Finally if the user is not logged in, get only Environment Id from events that are marked to be displayed for client (ClientFlag).
You need a new variable.