I would like to use the new JSON Columns feature of EF Core 7 to store and retrieve data in the following format in and from my PostgreSQL database:
{
"Name": "Email_AND_Phone_OR_RootUser",
"Rules": [
["HasEmail", "HasPhone"],
["IsRoot"]
]
}
This array of string arrays has a dynamic length and the string arrays within it too. If i understand correctly, i should create an owned class, reference it in my entity and either add the appropriate data attribute or configure it OnModelCreating. In the examples i find in the internet, i don't see any use of lists or arrays within the JSON mapping class. Are the following mapping classes valid ?
public class Policy
{
[MaxLength(30)] public string Name { get; set; } = null!;
public List<List<string>> RuleBinding { get; set; } = new();
}
Or, as an array of string arrays:
public class Policy
{
[MaxLength(30)] public string Name { get; set; } = null!;
public string[][] RuleBinding { get; set; } = null!;
}
Also, is the use of JSON Columns appropriate in this case or not?