还有其他解决方法吗?除了使用Linqkit使用.AsExpandable()
。如果还有其他方法,请提供帮助。
private static IQueryable<Data.BidVehicle> PredicateBuilderQuery(IQueryable<Data.Vehicle> vehicles, List<string> MileAge)
{
var predicate = PredicateBuilder.True<Data.BidVehicle>();
foreach (var mpgc in MileAge)
{
int[] splitDash = SplitAndTrimDashInt(mpgc);
int min = splitDash[0];
int max = splitDash[1];
predicate = predicate.Or(p => p.IVehicle.Mileage >= min && p.IVehicle.Mileage <= max);
}
vehicles= vehicles.Where(predicate);
//vehicles= vehicles.AsExpandable().Where(predicate);
return vehicles;
}