HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In

Use filters to narrow down search results, or use them for database-like queries. 

The REST API and .NET client API support filtering on complex objects of different types to varying degree. Supported complex objects can be divided into these types:

  • Collections of native objects such as `IEnumerable<int>`.

  • Complex objects that have properties of native objects and/or complex objects, for example an Author class.

  • Collections of complex objects, such as `IEnumerable<Author>`.

## Collection of native objects

The first type is covered by the documentation for each _native_ type. For instance if you want to know how to filter on a property of type `IEnumerable<string>`, see [Strings](🔗).

## Complex objects with properties of native objects

The second type, _complex objects_, such as a property of type `Author` is straight forward. You can filter on its native properties just as if they were apart of the type we are searching for. For instance, to find blog posts authored by _Winston Churchill_, you could use the below code.


One might wonder what happens if the `Author` property is null. Contrary to LINQ, no exception is thrown. The filter simply does not match.

## Complex object collections

The final type of complex objects that you can filter on is a _collection of complex objects_, such as `IEnumerable<Author>`. The .NET client API has a filter method named MatchContained, which you can use to filter on properties of native types in objects contained in collections. Imagine that the `BlogPost` class no longer has an `Author` property but instead an Authors property of type `IEnumerable<Author>`. Next, use the `MatchContained` method to find blog posts whose Author property contains an `Author` with a specific name.



The `MatchContained` syntax is a bit different from other filtering methods. The first argument is an expression identifying the property that we want to filter on. The second argument is the value.

Also, while the `MatchContained` method lets you filter on a single field in an object in a list, you cannot use it to express multiple conditions on the same object in the list. That is, use it to find blog posts that have an author named _Winston Churchill_ and an author with a specific email address. You cannot use it to find blog posts with a specific author that have both a specific name and a specific email address.