Let's say we have an entity class that looks like this:
public class SerializedEntity
{
public JsonDocument Payload { get; set; }
public SerializedEntity(JsonDocument payload)
{
Payload = payload;
}
}
According to npsql this generates a table with column payload of type jsonb for this class which is correct.
Now what I would like to do is take any class instance and store it as payload in this table e.g.:
public class Pizza {
public string Name { get; set; }
public int Size { get; set; }
}
should then be possible to be retrieved as an object with following structure:
{Name: "name", Size: 10}
So I need something like this:
var pizza = new Pizza("Margharita", 10);
var se = new SerializedEntity(someConverter.method(pizza))