.NET - Collection.Query.Where()

Adds a new where clause to a query, which filters the data returned.

using Nitric.Sdk;
using Nitric.Sdk.Resource;
class Profile {
public string Name { get; set; }
public float Age { get; set; }
}
var profiles = Nitric.Collection<Profile>("profiles").With(
CollectionPermission.Reading, CollectionPermission.Writing, CollectionPermission.Deleting
);
var profilesQuery = profiles.Query().Where("name", "startsWith", "T");
Nitric.Run();

Parameters

  • Name
    field
    Required
    Required
    Type
    string
    Description

    The document field to query.

  • Name
    operation
    Required
    Required
    Type
    string
    Description

    The query operation to perform.
    Valid values are: startsWith | == | != | >= | <= | > | <.

  • Name
    value
    Required
    Required
    Type
    string | double | int | bool
    Description

    The value to compare against.

Notes

Where clauses combined together are always considered AND

Examples

A simple query

using Nitric.Sdk;
using Nitric.Sdk.Resources;
var profiles = Nitric.Collection("profiles").With(CollectionPermission.Reading);
var profileQuery = profiles.Query().Where("firstName", "==", "Drake");
Nitric.Run();

Combining where clauses

using Nitric.Sdk;
using Nitric.Sdk.Resources;
var profiles = Nitric.Collection("profiles").With(CollectionPermission.Reading);
var profileQuery = profiles.Query()
.Where("firstName", "==", "Drake")
.Where("age", ">=", 21);
Nitric.Run();

See also

Last updated on Dec 24, 2024