Nesting OR using Linq PredicateBuilder
问题 I am using predicate builder to write the following code: IEnumerable<int> ids= new List<int> { 47, 48 }; var predicate = PredicateBuilder.False<Customer>(); predicate = predicate.And(x => x.CreatedAt >= fromDate && x.CreatedAt <= toDate); foreach (var id in ids) { predicate = predicate.Or(x => x.Source.Id == id); } var result = Database.Set<Customer>().AsExpandable() .Where(predicate) .ToList(); The SQL generated looks like (just the WHERE clause): WHERE ([Filter6].[SourceId] IN (@p__linq__0