How do you conditionally combine filters using the MongoDB C# driver? -
consider following filter:
var builder = builders<product>.filter; var filter = builder.gte(i => i.price, criteria.minprice) & builder.lte(i => i.price, criteria.maxprice); if (0 != criteria.categoryid) //combine following filter previous filter. how?? var criteriafilter = builder.eq(i => i.categoryid, criteria.categoryid);
how combine criteriafilter , filter?
if (criteria.categoryid != 0) { var criteriafilter = builder.eq(i => i.categoryid, criteria.categoryid); filter = filter & criteriafilter; }
Comments
Post a Comment