• Start

Languages

/

.NET

/

Methods

Insert

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

Inserts one or multiple records in the database.

Method Syntax
await db.Insert<T>(table, data)

Arguments

Description

table

Optionally pass along a table to insert into.

data

Either a single document/record or an array of documents/records to insert

cancellationToken

The cancellationToken enables graceful cancellation of asynchronous operations.

var posts = new List<Post>
{
    new Post
    {
        Id = ("post", "First"),
        Title = "An article",
        Content = "This is the first article"
    },
    new Post
    {
        Id = ("post", "Second"),
        Title = "An article",
        Content = "This is the second article"
    }
};

await db.Insert("post", posts);

Was this page helpful?