asp.net mvc - Filter list by date and time MVC/C# -


i'm trying filter list according give start , end date, give me proper rows according info i've entered, not. below query see problem in logic?

public list<myticket> filteredtickets => tickets.where(x =>         (string.isnullorempty(tickettype) || x.requesttypeid == tickettype) &&         (startdate == null || x.datelogged >= startdate) && (enddate == null || x.datelogged <= enddate)).tolist(); 

you need fix follows:

public list<myticket> filteredtickets =         tickets.where(x =>         (!string.isnullorempty(tickettype) && x.requesttypeid == tickettype) &&         (startdate != null && x.datelogged >= startdate) &&          (enddate != null && x.datelogged <= enddate)).tolist(); 

Comments