Skip to content

Instantly share code, notes, and snippets.

@zHaytam
Last active May 17, 2020 23:49
Show Gist options
  • Save zHaytam/4eac0564b10aeef35a663bed7a4f06c5 to your computer and use it in GitHub Desktop.
Save zHaytam/4eac0564b10aeef35a663bed7a4f06c5 to your computer and use it in GitHub Desktop.
var predicate = new DynamicFilterBuilder<Product>()
.And("Enabled", FilterOperator.Equals, true)
.And(b => b.And("Brand", FilterOperator.Equals, "Nike").Or("Brand", FilterOperator.Equals, "Adidas"))
.And(b => b.And("Price", FilterOperator.GreaterThanOrEqual, 20).And("Price", FilterOperator.LessThanOrEqual, 100))
.Build();
var products = _dbContext.Products.AsQueryable().Where(predicate).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment