JasinCole
Well-known member
- Joined
- Feb 16, 2023
- Messages
- 66
- Programming Experience
- 1-3
What am I doing wrong? This shouldn't be that hard yet it doesn't work.
Given
I expect
All the while this works just fine in another section of code, which proves to me the JSON file is being read and does contain the data, or this would fail.
Given
C#:
{
"LedgerAccounts": {
"GeneralChecking": 1000,
"PayrollChecking": 1002,
"Savings": 1030,
"CertificateOfDeposit": 1040,
"ContractReceivables": 1120,
"ServiceReceivables": 1130,
"TradeReceivables": 1140,
"OtherReceivables": 1190,
"TradeAccountsPayable": 2000,
"SalesTaxPayable": 2200,
"StatePayrollTaxesPayable": 2310,
"FederalUnemploymentTaxActPayable": 2330,
"UnionBenefitsPayable": 2335,
"HealthInsurancePayable": 2345,
"CurrentPortionOfLongTermDebt": 2650
}
}
I expect
C#:
private IConfiguration _configuration; //This is assigned in the constructor using DI and it has the correct provider with the correct data
IConfigurationSection section = _configuration.GetSection("LedgerAccounts"); //section has a value of null, I expect it should have a string of the values in that section
All the while this works just fine in another section of code, which proves to me the JSON file is being read and does contain the data, or this would fail.
C#:
var mssqlDatabase = new MssqlDatabase();
configuration.GetSection(nameof(MssqlDatabase)).Bind(mssqlDatabase);
Last edited: