• Start

Languages

/

.NET

/

Methods

Create

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

Creates a record in the database.

Method Syntax
await db.Create<T>(resource, data)

Arguments

Description

thing

The table name or a RecordId to create.

data

The document / record data to insert.

cancellationToken

The cancellationToken enables graceful cancellation of asynchronous operations.

// Create a record with a random ID
var person = await db.Create<Person>("person");

// Create a record with a random ID & specific fields
var person = await db.Create("person", new Person { Name = "Tobie" });

// Create a record with a specific ID
var personToCreate = new Person
{
    Id = ("person", "tobie"),
    Name = "Tobie",
    Settings = new Settings
    {
        Active = true,
        Marketing = true,
    },
};
var result = await db.Create(personToCreate);

Was this page helpful?