public IDataResult <List <CarDetailDto> > GetCarsDetails(CarDetailFilterDto filterDto) { //Expression propertyExp,someValue,containsMethodExp,combinedExp; //Expression<Func<Car, bool>> exp = c => true, oldExp; //MethodInfo method; //var parameterExp = Expression.Parameter(typeof(Car), "type"); //foreach (PropertyInfo propertyInfo in filterDto.GetType().GetProperties()) //{ // if (propertyInfo.GetValue(filterDto,null) != null) // { // oldExp = exp; // propertyExp = Expression.Property(parameterExp, propertyInfo.Name); // method = typeof(int).GetMethod("Equals", new[] { typeof(int) }); // someValue = Expression.Constant(filterDto.GetType().GetProperty(propertyInfo.Name).GetValue(filterDto, null), typeof(int)); // containsMethodExp = Expression.Call(propertyExp, method, someValue); // exp = Expression.Lambda<Func<Car, bool>>(containsMethodExp, parameterExp); // combinedExp = Expression.AndAlso(exp.Body,oldExp.Body); // exp = Expression.Lambda<Func<Car, bool>>(combinedExp, exp.Parameters[0]); // } //} return(new SuccessDataResult <List <CarDetailDto> >(_iCarDal.GetAllCarDetailsByFilter(filterDto))); }
public IDataResult <List <CarDetailDto> > GetCarsDetailsByFilter(CarDetailFilterDto filterDto) { return(new SuccessDataResult <List <CarDetailDto> >(_carDal.GetAllCarDetailsByFilter(filterDto))); }