I want to give multiple where condition while binding data in mvc using linq. I tried where condition same as sql query and other type also but didnt work and showing error i.e.
The specified type member 'YearID' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
Here is my code which I tried latest,
public ActionResult FilterImage(int yearID, int eventID, int branchID)
{
var content = db.eventRegistration.Select(s => new
{
s.EventRegistrationID,
s.Image,
s.IsActive
});
List<EventRegistrationViewModel> contentModel = content
.Select(item => new EventRegistrationViewModel()
{
EventRegistrationID = item.EventRegistrationID,
Image = item.Image,
IsActive = item.IsActive
})
.Where(c => c.IsActive == true && c.YearID == yearID && c.BranchID == branchID)
.Take(15).ToList();
return View(contentModel);
}
this code is not working for multiple where condition.
I know and this question is almost asked previous time but then also that answer is didn't work for this solution.
Thank You.