【发布时间】:2020-11-12 07:53:40
【问题描述】:
我正在使用IConfiguration.GetSection 从配置文件中检索配置信息:
var loggingProviders = Config.GetSection( "Logging" ).Get<LoggingProviders>();
这很好用,但我只想检索已启用的条目,所以我想执行以下任一操作:
var loggingProviders = Config.GetSection( "Logging" ).Get<LoggingProviders>().Where( x => x.Enabled == true );
var loggingProviders = Config.GetSection( "Logging" ).Where( x => x.Enabled == true ).Get<LoggingProviders>();
但我总是陷入死胡同,任何建议都将不胜感激!
【问题讨论】:
-
在设置文件中显示部分的外观。
标签: asp.net-core asp.net-mvc-5 asp.net-core-3.1 c#-8.0