Open ghost opened 4 years ago
Have you tried using .ToObject
var example = await CrossCloudFirestore.Current.Instance.GetDocument("path/path").GetDocumentAsync(); var your_NetObject = example.ToObject<Models.YourObject>();
If your document that has a subcollection in the database marches your .net class then you'll be able to get that document as a .net class.
The easiest way of making sure your .net class marches your document in the database is this:
get your document:
var example = await CrossCloudFirestore.Current.Instance.GetDocument("path/path").GetDocumentAsync();
Console.WriteLine(example.Data);
This will give you the document in a Json format if the document exists. Copy that Json and go to the site: http://json2csharp.com/
It will generate a .NET class for you. If it does not march your class then you'll have to use the generated class or think of a way of uploading your document to march your class.
After that, then you can easily do:
var your_NetObject = example.ToObject<Models.YourObject>();
I have a subcollection in my document, but its not in the .Data
Do you get a Json Object when you log .Data?
Can you please provide a little code snippet in which you show how to get a document which includes a subcollection and that maps this whole document with subcollection to a related .net class? Thanks.