Navigation

Data Type Queries - .NET SDK

You cannot query Realm Collections, Dictionaries, or Sets by using Linq. You can query them, however, with string queries. The following code shows how to use string queries for these types:

// Find all Inventory items that have a name of "Prickly Pear"
var certainCacti = realm.All<Inventory>().Filter("Plants.Name == 'Prickly Pear'");
// Find all Inventory items that have a name of "Prickly Pear"
var greenPlants = realm.All<Inventory>().Filter("Plants.Color CONTAINS[c] 'Green'");
// Find all Inventory items that have "Petunia"
// as a key in their PlantDict.
var petunias = realm.All<Inventory>()
.Filter("PlantDict.@keys == 'Petunia'");
// Find all Inventory items that have at least one value in their
// IntDict that is larger than 5
var matchesMoreThanFive = realm.All<Inventory>()
.Filter("NullableIntDict.@values > 5");
// Find all Inventory items where any RequiredStringsDict has a key
// "Foo", and the value of that key contains the phrase "bar"
// (case insensitive)
var matches = realm.All<Inventory>().Filter("RequiredStringsDict['foo'] CONTAINS[c] 'bar'");
// Find all Plants that have "Prickly Pear" in the name
var pricklyPear = realm.All<Inventory>()
.Filter("PlantSet.Name CONTAINS 'Prickly Pear'");
// Find all Inventory items that have at least one value in their
// IntDict that is larger than 5
var moreThan100 = realm.All<Inventory>()
.Filter("DoubleSet.@values > 100");
Give Feedback

On this page

  • Overview
  • Lists
  • Dictionaries
  • Sets