Nested Relational Queries
Autofilter supports related entities querying at version 1.1.0
and above. You can filter your One-to-Many, Many-To-Many or One-To-One related entities with nested FilterBase objects.
Let's make a sample.
Over Collections
- Entity class anatomy:
- Let's create a dto to filter by
Language
property.
- Just apply filter to Blogs:
- You can send following requests to check result. No any include required for filtering! That's awesome!
QueryString | Generated LINQ |
---|---|
?Comments.Language=en |
db.Blogs.Where(x => x.Comments.Any(a => a.Language == "en")) |
?comments.language=en&message=awesome |
db.Blogs.Where(x => x.Message.Contains("awesome") && x.Comments.Any(a => a.Language == "en")) |
Over Objects
- Entity class anatomy:
- Let's create a dto to filter by
Language
property.
- Then you can send following requests to check result. No any include required for filtering! That's awesome!
QueryString | Generated LINQ |
---|---|
?author.isPremium=True |
db.Blogs.Where(x => x.Author.IsPremium == true |
?author.isPremium=False&author.fullName=John |
db.Blogs.Where(x => x.Author.IsPremium == false && x.Author.FullName.Contains("John") |