benxu.AppPlatform.Supabase.PostgreSQL
3.2.8
dotnet add package benxu.AppPlatform.Supabase.PostgreSQL --version 3.2.8
NuGet\Install-Package benxu.AppPlatform.Supabase.PostgreSQL -Version 3.2.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="benxu.AppPlatform.Supabase.PostgreSQL" Version="3.2.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="benxu.AppPlatform.Supabase.PostgreSQL" Version="3.2.8" />
<PackageReference Include="benxu.AppPlatform.Supabase.PostgreSQL" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add benxu.AppPlatform.Supabase.PostgreSQL --version 3.2.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: benxu.AppPlatform.Supabase.PostgreSQL, 3.2.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package benxu.AppPlatform.Supabase.PostgreSQL@3.2.8
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=benxu.AppPlatform.Supabase.PostgreSQL&version=3.2.8
#tool nuget:?package=benxu.AppPlatform.Supabase.PostgreSQL&version=3.2.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
benxu.AppPlatform.Supabase.PostgreSQL
Supabase PostgreSQL 實作套件,使用 Supabase.Postgrest 提供強型別的 CRUD、查詢與 RPC 呼叫能力,適合在 .NET MAUI App 中透過 Supabase 的 Data API 存取 PostgreSQL。
功能特色
- 使用
Supabase.Postgrest實作強型別資料模型查詢。 - 提供
Insert / Upsert / Query / Update / Delete / RPC服務介面。 - 若系統中已有
IAuthService,可自動帶入使用者 JWT,配合 Supabase RLS。 - 保持套件內聚,不把
Supabase.Postgrest依賴擴散到既有平台 Core 抽象。
安裝
dotnet add package benxu.AppPlatform.Supabase.PostgreSQL
使用方式
1. 註冊服務
using benxu.AppPlatform.Supabase.PostgreSQL.Extensions;
builder.Services.AddSupabasePostgreSql(options =>
{
options.ProjectUrl = "https://your-project.supabase.co";
options.AnonKey = "YOUR_SUPABASE_ANON_KEY";
options.Schema = "public";
options.UseAuthTokenWhenAvailable = true;
});
2. 定義資料模型
using Supabase.Postgrest.Attributes;
using Supabase.Postgrest.Models;
[Table("profiles")]
public class ProfileModel : BaseModel
{
[PrimaryKey("id", false)]
public Guid Id { get; set; }
[Column("display_name")]
public string DisplayName { get; set; } = string.Empty;
[Column("avatar_url")]
public string? AvatarUrl { get; set; }
}
3. 查詢與寫入資料
using benxu.AppPlatform.Supabase.PostgreSQL.Abstractions;
public class ProfileRepository
{
private readonly ISupabasePostgreSqlService _postgreSqlService;
/// <summary>
/// 建立 ProfileRepository
/// </summary>
/// <param name="postgreSqlService">Supabase PostgreSQL 服務</param>
public ProfileRepository(ISupabasePostgreSqlService postgreSqlService)
{
_postgreSqlService = postgreSqlService;
}
/// <summary>
/// 取得最近更新的使用者資料
/// </summary>
/// <returns>資料清單</returns>
public async Task<IReadOnlyList<ProfileModel>> GetLatestProfilesAsync()
{
var result = await _postgreSqlService.QueryAsync<ProfileModel>(query =>
query.OrderByDescending("updated_at")
.Limit(20));
return result.IsSuccess ? result.Data : Array.Empty<ProfileModel>();
}
}
注意事項
- Model 必須繼承
BaseModel,並使用[Table]、[PrimaryKey]、[Column]屬性。 GetByIdAsync()與DeleteByIdAsync()目前僅支援單一主鍵欄位。- 若你的表格使用 RLS,建議同時註冊
benxu.AppPlatform.Supabase.Auth,讓本套件可自動帶入使用者 Access Token。
依賴項目
Supabase.Postgrest(4.1.0)benxu.AppPlatform.CoreMicrosoft.Maui.Controls
授權
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. net10.0-ios26.0 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-android36.0
- benxu.AppPlatform.Core (>= 3.2.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Supabase.Postgrest (>= 4.1.0)
- Xamarin.AndroidX.Activity (>= 1.10.1.3)
- Xamarin.AndroidX.Activity.Ktx (>= 1.10.1.3)
- Xamarin.AndroidX.Collection (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Jvm (>= 1.5.0.3)
- Xamarin.AndroidX.Collection.Ktx (>= 1.5.0.3)
- Xamarin.Build.Download (>= 0.11.4)
-
net10.0-ios26.0
- benxu.AppPlatform.Core (>= 3.2.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Maui.Controls (>= 10.0.0)
- Supabase.Postgrest (>= 4.1.0)
- Xamarin.Build.Download (>= 0.11.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on benxu.AppPlatform.Supabase.PostgreSQL:
| Package | Downloads |
|---|---|
|
benxu.AppPlatform.MAUI.Bootstrap
Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.8 | 79 | 7/7/2026 |