IHasResourceId
The lower-level resource ID contract used by FGA pages and checks.
IHasResourceId is the lower-level contract authorized pages read. It exposes the FGA resource ID on a domain entity so ToPageAsync can check each app row against the resources the subject can access.
public interface IHasResourceId
{
string ResourceId { get; }
}For protected domain entities whose resource lifecycle should be managed by SqlOS, prefer ISqlOSResourceEntity. It extends IHasResourceId with resource metadata used by SqlOSDbContext<TContext> during SaveChanges / SaveChangesAsync.
public sealed class Workspace : ISqlOSResourceEntity
{
public Guid Id { get; set; }
public string ResourceId { get; set; } = "";
public string Name { get; set; } = "";
public string OrganizationId { get; set; } = "";
public string ResourceTypeId => "workspace";
public string ResourceName => Name;
public string ParentResourceId => $"org::{OrganizationId}";
public string? ResourceDescription => null;
public bool ResourceIsActive => true;
}ToPageAsync uses ResourceId to return only the rows whose resource the subject can access, one page at a time:
var page = await db.Workspaces
.OrderBy(x => x.Name)
.ToPageAsync(subjectId, "WORKSPACE_VIEW", pageSize: 20, cursor, ct);T must implement IHasResourceId, and the query must start from a DbSet of a context deriving from SqlOSDbContext<TContext>. For one row, pass its ResourceId to CheckAccessAsync.
Use plain IHasResourceId directly for lower-level/manual resources where your application owns the FGA resource lifecycle. Use ISqlOSResourceEntity for the normal SDK path.
Index the columns a list sorts by, as for any database. SqlOS keeps a copy of every index of an IHasResourceId entity, and of its primary key, under every node of the resource tree, so a page costs about a page for any caller:
modelBuilder.Entity<Workspace>(entity =>
{
entity.HasKey(x => x.Id);
entity.Property(x => x.Name).HasMaxLength(200);
entity.HasIndex(x => new { x.Name, x.Id }); // (Name, Id)
});ResourceId stays the only connection between your table and SqlOS: the copies live in tables of SqlOS's own (SqlOSFgaPage_Workspaces_Name, SqlOSFgaPage_Workspaces_Id) that your next migration creates. Indexes on ResourceId or on a foreign key are lookups and get no copy. Order columns are non-nullable, strings need a maximum length, and the entity needs a single-column primary key; an index that breaks a rule gets no copy and one startup warning. See Paginating authorized lists.