Skip to content

Instantly share code, notes, and snippets.

@c10r
Created June 20, 2026 03:39
Show Gist options
  • Select an option

  • Save c10r/4810fcd1aa00928c248ab9b8c7924a3f to your computer and use it in GitHub Desktop.

Select an option

Save c10r/4810fcd1aa00928c248ab9b8c7924a3f to your computer and use it in GitHub Desktop.
Linq example
public sealed class AppDbContext : DbContext
{
public DbSet<Customer> Customers => Set<Customer>();
public DbSet<Order> Orders => Set<Order>();
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
options.UseTurso("libsql://my-db.turso.io", new TursoOptions
{
AuthToken = "<token>"
});
}
}
public sealed class Customer
{
public long Id { get; set; }
public string Name { get; set; } = "";
public string Email { get; set; } = "";
public bool IsActive { get; set; }
public List<Order> Orders { get; set; } = [];
}
public sealed class Order
{
public long Id { get; set; }
public long CustomerId { get; set; }
public Customer Customer { get; set; } = null!;
public decimal Total { get; set; }
public DateTime CreatedAt { get; set; }
}
await using var db = new AppDbContext();
var activeCustomers = await db.Customers
.Where(c => c.IsActive)
.OrderBy(c => c.Name)
.Take(50)
.ToListAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment