C#: Fetch data

Performs vertical filtering with SELECT.

Examples

Getting your data

// Given the following Model (City.cs)
[Table("cities")]
class City : BaseModel
\{
    [PrimaryKey("id")]
    public int Id \{ get; set; \}

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

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

    //... etc.
\}

// A result can be fetched like so.
var result = await supabase.From<City>().Get();
var cities = result.Models

Selecting specific columns

// Given the following Model (Movie.cs)
[Table("movies")]
class Movie : BaseModel
\{
    [PrimaryKey("id")]
    public int Id \{ get; set; \}

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

    [Column("created_at")]
    public DateTime CreatedAt \{ get; set; \}

    //... etc.
\}

// A result can be fetched like so.
var result = await supabase
  .From<Movie>()
  .Select(x => new object[] \{x.Name, x.CreatedAt\})
  .Get();

Query foreign tables

var data = await supabase
  .From<Transactions>()
  .Select("id, supplier:supplier_id(name), purchaser:purchaser_id(name)")
  .Get();

Filtering with inner joins

var result = await supabase
  .From<Movie>()
  .Select("*, users!inner(*)")
  .Filter("user.username", Operator.Equals, "Jane")
  .Get();

Querying with count option

var count = await supabase
  .From<Movie>()
  .Select(x => new object[] \{ x.Name \})
  .Count(CountType.Exact);

Querying JSON data

 var result = await supabase
  .From<Users>()
  .Select("id, name, address->street")
  .Filter("address->postcode", Operator.Equals, 90210)
  .Get();