C#: Insert data

Performs an INSERT into the table.

Examples

Create a record

[Table("cities")]
class City : BaseModel
\{
    [PrimaryKey("id", false)]
    public int Id \{ get; set; \}

    [Column("name")]
    public string Name \{ get; set; \}

    [Column("country_id")]
    public int CountryId \{ get; set; \}
\}

var model = new City
\{
  Name = "The Shire",
  CountryId = 554
\};

await supabase.From<City>().Insert(model);

Bulk create

[Table("cities")]
class City : BaseModel
\{
    [PrimaryKey("id", false)]
    public int Id \{ get; set; \}

    [Column("name")]
    public string Name \{ get; set; \}

    [Column("country_id")]
    public int CountryId \{ get; set; \}
\}

var models = new List<City>
\{
  new City \{ Name = "The Shire", CountryId = 554 \},
  new City \{ Name = "Rohan", CountryId = 553 \},
\};

await supabase.From<City>().Insert(models);

Fetch inserted record

var result = await supabase
  .From<City>()
  .Insert(models, new QueryOptions \{ Returning = ReturnType.Representation \});