asp.net mvc 3 - Where clause like syntax in lambda expression -
i searched alot couldnt find right resolution problem.
what i'm trying basic in sql dont know how make work in lambda expression here im trying do:
filteredinorderquery = mycontext.websites.orderby(website.currentorderby + " " + website.sortorder).where( x => (website.websitefilterlist.contains(x.site.tostring())) && (website.cityfilterlist.contains(x.city.tostring())) ).select(x => new websitedata( x.rowid, x.pagetype, x.site, x.creationdate ?? datetime.today, x.expirationdate ?? datetime.today, x.domainregistrar, x.pin, x.area, x.city, ((x.expirationdate ?? datetime.today) - datetime.today).days.tostring() + " days"));
websitefilterlist , cityfilterlist both can empty can contain more 1 item.
point should able records if pass of list empty (if list empty should records of column)
and if im passing both list more 1 entry ..records matching entries should appear.
currently not happening error when of list empty. although if of list empty must records. common requirement couldnt find solution.
where(x => (!website.websitefilterlist.any() || website.websitefilterlist.contains(x.site.tostring())) && (!website.cityfilterlist.any() || website.cityfilterlist.contains(x.city.tostring())))
Comments
Post a Comment