See how to do CRUD operations with Firebase Realtime Database in C#.Net
You can see the full project in Github
- Open a new Project.
- Install Firesharp in Nougat Package manager
Tools --> Noget Package Manager --> Manage packages for solution
How can I configure FireSharp?
IFirebaseConfig config = new FirebaseConfig
{
AuthSecret = "your_firebase_secret",
BasePath = "https://yourfirebase.firebaseio.com/"
};
IFirebaseClient client = new FirebaseClient(config);
So far, supported methods are :
Set
var todo = new Todo {
name = "Execute SET",
priority = 2
};
SetResponse response = await _client.SetAsync("todos/set", todo);
Todo result = response.ResultAs<Todo>(); //The response will contain the data written
Push
var todo = new Todo {
name = "Execute PUSH",
priority = 2
};
PushResponse response =await _client.PushAsync("todos/push", todo);
response.Result.name //The result will contain the child name of the new data that was added
Get
FirebaseResponse response = await _client.GetAsync("todos/set");
Todo todo=response.ResultAs<Todo>(); //The response will contain the data being retreived
Update
var todo = new Todo {
name = "Execute UPDATE!",
priority = 1
};
FirebaseResponse response =await _client.UpdateAsync("todos/set", todo);
Todo todo = response.ResultAs<Todo>(); //The response will contain the data written
Delete
FirebaseResponse response =await _client.DeleteAsync("todos"); //Deletes todos collection
Console.WriteLine(response.StatusCode);
Listen Streaming from the REST API
EventStreamResponse response = await _client.OnAsync("chat", (sender, args, context) => {
System.Console.WriteLine(args.Data);
});
//Call dispose to stop listening for events
response.Dispose();




0 Comments