I have a methods that takes multiple arrays and filter data using linq, the problem I am having is that one or more arrays could be null and I am not sure how to handle null arrays in Linq.:
public IPagedList<SGProduct> GetFilteredProducts(string catID, string[] houseID, int page = 1)
{
return MongoContext.Products.AsQueryable<SGProduct>().AsEnumerable().Where(x =>houseID.Contains(x.HouseID.ToString()) && x.ProductCategoryID.ToString() == catID).ToList().ToPagedList(page, 6);
}
The houseID array could be null also I will have more parameters to this method like Size array etc.
Any suggestions. Thanks