百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

firebase-database-dotnet

> 编程语言
开源

用于 Firebase 实时数据库的 C# 库。

671 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Firebase 实时数据库的 C# 库。

FirebaseDatabase.net

Simple wrapper on top of Firebase Realtime Database REST API. Among others it supports streaming API which you can use for realtime notifications.

For Authenticating with Firebase checkout the Firebase Authentication library and related blog post

To upload files to Firebase Storage checkout the Firebase Storage library and related blog post

Installation

// Install release version
Install-Package FirebaseDatabase.net

// Install pre-release version
Install-Package FirebaseDatabase.net -pre

Supported frameworks

.NET Standard 2.0 - see https://github.com/dotnet/standard/blob/master/docs/versions.md for compatibility matrix

Usage

Authentication

The simplest solution where you only use your app secret is as follows:

var auth = "ABCDE"; // your app secret
var firebaseClient = new FirebaseClient(
  "",
  new FirebaseOptions
  {
    AuthTokenAsyncFactory = () => Task.FromResult(auth) 
  });

Note that using app secret can only be done for server-side scenarios. Otherwise you should use some sort of third-party login.

var firebaseClient = new FirebaseClient(
  "",
  new FirebaseOptions
  {
    AuthTokenAsyncFactory = () => LoginAsync()
  });

...

public static async Task LoginAsync()
{
  // manage oauth login to Google / Facebook etc.
  // call FirebaseAuthentication.net library to get the Firebase Token
  // return the token
}
  

As you can se, the AuthTokenAsyncFactory is of type Func>. This is to allow refreshing the expired token in streaming scenarios, in which case the func is called to get a fresh token.

Using service account

See this issue

Querying

C#

using Firebase.Database;
using Firebase.Database.Query;

' Since the dinosaur-facts repo no longer works, populate your own one with sample data in "sample.json"
var firebase = new FirebaseClient("https://dinosaur-facts.firebaseio.com/");
var dinos = await firebase
  .Child("dinosaurs")
  .OrderByKey()
  .StartAt("pterodactyl")
  .LimitToFirst(2)
  .OnceAsync();
  
foreach (var dino in dinos)
{
  Console.WriteLine($"{dino.Key} is {dino.Object.Height}m high.");
}

VB.net

Imports Firebase.Database
Imports Firebase.Database.Query

' Since the dinosaur-facts repo no longer works, populate your own one with sample data in "sample.json"
Dim client = New FirebaseClient("https://dinosaur-facts.firebaseio.com/")

Dim dinos = Await client _
    .Child("dinosaurs") _
    .OrderByKey() _
    .StartAt("pterodactyl") _
    .LimitToFirst(2) _
    .OnceAsync(Of Dinosaur)

For Each dino In dinos
    Console.WriteLine($"{dino.Key} is {dino.Object.Height}m high.")
Next

Saving & deleting data

…

Realtime streaming

C#

using Firebase.Database;
using Firebase.Database.Query;
using System.Reactive.Linq;
...
var firebase = new FirebaseClient("https://dinosaur-facts.firebaseio.com/");
var observable = firebase
  .Child("dinosaurs")
  .AsObservable()
  .Subscribe(d => Console.WriteLine(d.Key));
  

VB.net

Imports System.Reactive.Linq
Imports Firebase.Database
Imports Firebase.Database.Query
' ...
Dim client = New FirebaseClient("https://dinosaur-facts.firebaseio.com/")

child _
  .Child("dinosaurs") _
  .AsObservable(Of InboundMessage) _
  .Subscribe(Sub(f) Console.WriteLine(f.Key))

AsObservable methods returns an IObservable which you can take advantage of using Reactive Extensions

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言