我需要阅读 net 6 中的 web api 项目的这一部分
{
"ProductsMigration": {
"Products": [
{
"Product":
{
"SourceAppId": 4215,
"TargetAppId": 6218
}
}
]
}
}
我创建了这个类:
internal class ProductMigration
{
internal class ProductMigrationItem
{
public string SourceAppId { get; private set; }
public string TargetAppId { get; private set; }
}
public ProductMigrationItem Product { get; set; }
}
这是读取设置的代码:
var items = _Configuration.GetSection("ProductsMigration:Products").Get<ProductMigration[]>();
items.count 为 1 但 SourceAppId 和 TargetAppId 为空。