Closed mastertheef closed 3 years ago
Did the problem was solved? If not, please show your code when you call the OnceSingleAsync()
When I do .OnceSingleAsync<object>
, I notice that the object returned is not flat. It's in a format like { "unique_id": {...}}, where {...} is the type I want OnceSingleAsync<T>
to deserialize to and "unique_id" is unknown at the time of querying (it's generated when the record was added to the real time database). Since we only care about the data underneath the unique_id, and the unique_id will be different from record to record, there's no way to write a class hierarchy for the JSON deserializer.
The easiest way to overcome this is to apply a [JsonConverter(typeof(ConverterClassName))]
to the class you are trying to deserialize to. Then, in the converter, you can handle the nested data properly.
Here's a link to the converter documentation: Custom Converter
Here's a link to a good solution for writing converters: Templated Converter
There may be a way to structure the query better to only return the data underneath the unique_id, but I couldn't find a way through the API.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing the issue due to inactivity. Feel free to re-open
OnceSingleAsync method always returns an object with empty fields.
public class Model { public Id { get; set; } public string Name { get; set; } }
will return an object like
{Id: Empty.Guid; Name: ''}