C# Firestore Save A Custom Class

Viewed 24

I'm trying to save an instance of the class below into my Firestore Database:

public class Test
{
  public string a;
  public int b;
  
  public Test(string a, int b)
  {
    this.a = a;
    this.b = b;
  }
}

From what I've seen, Firestore is a NoSQL database, and my goal here is to save an instance of any arbitrary class as an object

[FirestoreData]
public class SaveData
{
  [FirestoreProperty] public Test test1 { get; set; } // will result in 'ArgumentException: Unable to create convertor for type Test

  [FirestoreProperty] public int test2 { get; set; } // works just fine
}

My question is, how can I save an instance of any class? In the documentation they suggest using a Dictionary<string, object>. but since I'm using nested objects which are subject for changes, that's not an ideal solution.

Thanks!

0 Answers
Related