New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested Queries don't work with CompareToAttribute #17
Comments
Temporary SolutionTemporary solution is creating a nested query.
public class CountryFilterDto : FilterBase
{
[StringFilterOptions(StringFilterOption.Contains)]
public string Name { get; set; }
}
public class CityFilterDto : PaginationFilterBase
{
[CompareTo("Name")]
[StringFilterOptions(StringFilterOption.Contains)]
public string Filter { get; set; }
public CountryFilterDto Country { get; set; }
}
public class CityFilterDto : PaginationFilterBase
{
private string filter;
[CompareTo("Name")]
[StringFilterOptions(StringFilterOption.Contains)]
public string Filter { get => filter; set => SetFilter(value); }
public CountryFilterDto Country { get; set; }
private void SetFilter(string value)
{
filter = value; // keep backing field.
if(Country == null)
Country = new CountryFilterDto();
Country.Name = value;
this.CombineWith = CombineType.Or; // Make sure combines with || instead of &&
}
} That's it! Nested query will work properly. This solution is temporary until solution of this issue. |
Merged
enisn
changed the title
Nested Queries doesn't work with CompareToAttribute
Nested Queries don't work with CompareToAttribute
Jan 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Following situation doesn't work for
Country.Name
:Expected Expression is:
.Where(x => x.Name.Contains("Turkey") || x.Country.Name.Contains("Turkey"))
Generated Expression is
.Where(x => x.Name.Contains("Turkey").Where(x.Name.Contains("Turkey")))
The text was updated successfully, but these errors were encountered: