I have a c# project and I'm trying to update a single value of an object using FireSharp. However, when I do, it deletes the other objects that are strings.
tldr question:
Is it possible to update only a single field of an object using Firesharp or do I have to include all fields when updating?
In the example on their GitHub, they set all fields with:
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
and then they update the fields with :
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
I know this is possible in other languages so I feel like this should be possible in FireSharp.
My Case:
for example if I have a class like StudentProfile:
class StudentProfile {
public string Firstname {get; set;}
public string Lastname {get; set;}
public int Age {get; set;}
}
when I uploaded to firebase, I use:
StudentProfile studentProfile = new StudentProfile
{
Firstname = "John",
Lastname = "Doe",
Age = 18
};
client.Set("Students/" + firebaseUserId + "/StudentProfile", studentProfile);
Now let's say I wanted to update the age. First I would get the info:
var result = client.Get("Students/" + firebaseUserId + "/StudentProfile");
StudentProfile student = result.ResultAs<StudentProfile>();
Now I want to update only the age. However, this is where it seems to update the Age
but then delete the other values that are strings
int newAge = student.Age + 1;
StudentProfile updatedStudent = new StudentProfile
{
Age = newAge
};
client.UpdateAsync("Students/" + firebaseUserId + "/StudentProfile, updatedStudent)
Is it possible to update only a single field of an object using Firesharp or do I have to include all fields when updating?
Basically, it's a pain if I have to consistently write out all of the fields every time I want to update something.