This is not a duplicate. I want to read a collection from appsettings.json in my .Net core project.
The config entries are like below
Cars": [
{
"Name":"BMW",
"Type":"Sedan",
"SedanProperty":"value"
},
{
"Name":"SUZUKI",
"Type":"SUV"
"SUVProperty":"value"
}
]
I need to load this to a single collection List
The classes are.
public class Car
{
public string Name;
}
public class Sedan:Car
{
public string SedanProperty;
}
public class SUV:Car
{
public string SUVProperty;
}
I am trying to do something like below
var cars= new List<Car>();
_configuration.GetSection("Cars").Bind(cars);
Any help on this is appreaciated