![]() |
VOOZH | about |
dotnet add package benxu.AppPlatform.Firebase.Firestore --version 3.2.7
NuGet\Install-Package benxu.AppPlatform.Firebase.Firestore -Version 3.2.7
<PackageReference Include="benxu.AppPlatform.Firebase.Firestore" Version="3.2.7" />
<PackageVersion Include="benxu.AppPlatform.Firebase.Firestore" Version="3.2.7" />Directory.Packages.props
<PackageReference Include="benxu.AppPlatform.Firebase.Firestore" />Project file
paket add benxu.AppPlatform.Firebase.Firestore --version 3.2.7
#r "nuget: benxu.AppPlatform.Firebase.Firestore, 3.2.7"
#:package benxu.AppPlatform.Firebase.Firestore@3.2.7
#addin nuget:?package=benxu.AppPlatform.Firebase.Firestore&version=3.2.7Install as a Cake Addin
#tool nuget:?package=benxu.AppPlatform.Firebase.Firestore&version=3.2.7Install as a Cake Tool
Firebase Cloud Firestore 實作套件,提供雲端 NoSQL 資料庫功能,支援文件操作、即時監聽、批次寫入和交易。
dotnet add package benxu.AppPlatform.Firebase.Firestore
// 方式 1: 使用 Bootstrap
builder.UseAppPlatform(options =>
{
options.UseFirestore(firestore =>
{
firestore.EnableOfflinePersistence = true;
firestore.CacheSizeMegabytes = 100;
});
});
// 方式 2: 手動註冊
builder.Services.AddFirestore(options =>
{
options.EnableOfflinePersistence = true;
});
重要: 資料模型必須實作 IFirestoreObject 介面,並使用 [FirestoreProperty] 屬性標記要序列化的屬性。
using Plugin.Firebase.Firestore;
public class User : IFirestoreObject
{
[FirestoreProperty("name")]
public string Name { get; set; } = "";
[FirestoreProperty("age")]
public int Age { get; set; }
[FirestoreProperty("email")]
public string Email { get; set; } = "";
[FirestoreProperty("createdAt")]
public DateTimeOffset CreatedAt { get; set; }
}
注意事項:
public,否則反射無法正確存取[FirestoreProperty] 中的名稱會成為 Firestore 文件中的欄位名稱DateTimeOffset(不是 DateTime),否則會發生類型轉換錯誤string, int, long, double, bool, DateTimeOffset, 陣列, 字典等@inject IFirestoreService Firestore
// 建立文件
var user = new User { Name = "張三", Age = 25 };
await Firestore.SetDocumentAsync("users", "user123", user);
// 讀取文件
var result = await Firestore.GetDocumentAsync<User>("users", "user123");
if (result.IsSuccess)
{
Console.WriteLine($"Name: {result.Data.Name}");
}
// 查詢集合
var queryResult = await Firestore.QueryCollectionAsync<User>(
"users",
q => q.WhereGreaterThan("Age", 18)
.OrderBy("Name")
.Limit(10)
);
// 即時監聽
var listener = Firestore.ListenToDocument<User>(
"users",
"user123",
onChanged: user => Console.WriteLine($"Updated: {user?.Name}"),
onError: ex => Console.WriteLine($"Error: {ex.Message}")
);
// 取消監聽
listener.Dispose();
| 選項 | 預設值 | 說明 |
|---|---|---|
| EnableOfflinePersistence | true | 是否啟用離線持久化 |
| CacheSizeMegabytes | 100 | 快取大小限制(MB) |
| EnableSsl | true | 是否啟用 SSL |
| EmulatorHost | null | 模擬器位址(例如: "10.0.2.2:8080") |
| EnableLogging | false | 是否啟用日誌 |
| TimeoutSeconds | 30 | 預設逾時時間(秒) |
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 net10.0-android36.0 is compatible. net10.0-ios26.0 net10.0-ios26.0 is compatible. |
Showing the top 2 NuGet packages that depend on benxu.AppPlatform.Firebase.Firestore:
| Package | Downloads |
|---|---|
|
benxu.AppPlatform.MAUI.Bootstrap
Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management. |
|
|
benxu.AppPlatform.Billing.RevenueCat
RevenueCat integration for in-app subscriptions in .NET MAUI. Provides real SDK integration for Android/iOS with optional simulator mode for testing. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.7 | 94 | 6/5/2026 |
| 3.2.6 | 122 | 5/30/2026 |
| 3.2.5 | 120 | 4/25/2026 |
| 3.2.4 | 98 | 4/25/2026 |
| 3.2.3 | 108 | 4/23/2026 |
| 3.2.2 | 115 | 4/22/2026 |
| 3.2.1 | 113 | 4/17/2026 |
| 3.2.0 | 108 | 4/11/2026 |
| 3.1.9 | 109 | 4/10/2026 |
| 3.1.8 | 103 | 4/10/2026 |
| 3.1.7 | 103 | 4/10/2026 |
| 3.1.6 | 105 | 4/10/2026 |
| 3.1.5 | 104 | 4/9/2026 |
| 3.1.4 | 119 | 4/7/2026 |
| 3.1.3 | 120 | 3/24/2026 |
| 3.1.2 | 111 | 3/23/2026 |
| 3.1.1 | 113 | 3/22/2026 |
| 3.1.0 | 104 | 3/22/2026 |
| 3.0.9 | 107 | 3/20/2026 |
| 3.0.8 | 109 | 3/19/2026 |