0

i need to read this section from web api project in net 6

{
  "ProductsMigration": {
    "Products": [
        {
            "Product": 
            {
            "SourceAppId": 4215,
            "TargetAppId": 6218
            }
        }
    ]
  }
}

I've created this class:

internal class ProductMigration
{
    internal class ProductMigrationItem
    {
        public string SourceAppId { get; private set; }

        public string TargetAppId { get; private set; }
    }
    public ProductMigrationItem Product { get; set; }

}

this the code to read the setting:

var items = _Configuration.GetSection("ProductsMigration:Products").Get<ProductMigration[]>();

items.count is 1 but SourceAppId and TargetAppId are null.

mason
  • 31,774
  • 10
  • 77
  • 121
FDB
  • 971
  • 16
  • 32

0 Answers0