• Start

Methods

Set

The .NET SDK for SurrealDB enables simple and advanced querying of a remote or embedded database.

Assigns a value as a parameter for this connection.

Method Syntax
await db.Set(key, value)

Arguments

Description

key

Specifies the name of the variable.

value

Assigns the value to the variable name.

cancellationToken

The cancellationToken enables graceful cancellation of asynchronous operations.

// Assign the variable on the connection
await db.Set("name", new Name { FirstName = "Tobie",
    LastName = "Morgan Hitchcock" });

// Use the variable in a subsequent query
await db.Query($"CREATE person SET name = $name");

// Use the variable in a subsequent query
await db.Query($"SELECT * FROM person WHERE name.first_name = $name.first_name");

You can remove the variable from the connection using the Unset() method.

Was this page helpful?