title: Configuration.GetSection in Asp.Net Core 2.0 getting all settings
body: <p>I am trying to learn the various ways to retrieve configuration info so I can determine the best path for setting up and using configuration for an upcoming project.</p>
  <p>I can access the various single settings using</p>
  <pre><code>var sm = new SmsSettings 
  {
      FromPhone = Configuration.GetValue&lt;string&gt;(&quot;SmsSettings:FromPhone&quot;),
  
      StartMessagePart = Configuration.GetValue&lt;string&gt;(&quot;SmsSettings:StartMessagePart&quot;),
  
      EndMessagePart = Configuration.GetValue&lt;string&gt;(&quot;SmsSettings:EndMessagePart&quot;)
  };
  </code></pre>
  <p>I also need to be able to count settings, determine values of certain settings etc. So I was building a parsing method to do these types of things and needed a whole section of the settings file, which is what I assumed GetSection did.
  Wrong.</p>
  <p>appsettings.json :</p>
  <pre><code>{
    &quot;ConnectionStrings&quot;: {
      &quot;DefaultConnection&quot;: &quot;Server=(localdb)\\mssqllocaldb;Database=TestingConfigurationNetCoreTwo;Trusted_Connection=True;MultipleActiveResultSets=true&quot;,
      &quot;ProductionConnection&quot;: &quot;Server=(localdb)\\mssqllocaldb;Database=TestingConfigurationNetCoreTwo_Production;Trusted_Connection=True;MultipleActiveResultSets=true&quot;
    },
    &quot;Logging&quot;: {
      &quot;IncludeScopes&quot;: false,
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Warning&quot;
      }
    },
    &quot;SmsSettings&quot;: {
      &quot;FromPhone&quot;: &quot;9145670987&quot;,
      &quot;StartMessagePart&quot;: &quot;Dear user, You have requested info from us on starting&quot;,
      &quot;EndMessagePart&quot;: &quot;Thank you.&quot;
    }
  }
  </code></pre>
  <p>This code:</p>
  <pre><code>var section = Configuration.GetSection(&quot;ConnectionStrings&quot;);
  </code></pre>
  <p>Returns these results:</p>
  <p><a href="https://i.stack.imgur.com/JQUjJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JQUjJ.png" alt="Image 1: variable properties" /></a></p>
  <p><a href="https://i.stack.imgur.com/ar6om.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ar6om.png" alt="Image 2: Drilling down into JsonConfigurationProvider" /></a></p>
  <p>A few questions arise.</p>
  <ol>
  <li>Why is this returning 3 different JsonConfigurationProviders, one of which includes every setting in the appsettings.json file (shown in Image 2)</li>
  <li>Why isn't GetSection(&quot;ConnectionStrings&quot;) actuall doing just that, returning the sub children of the ConnectionStrings</li>
  <li>Given number 2, how do you actually just retrieve the children of ConnectionStrings ?</li>
  <li>Assuming a model ConnectionStrings, with one property, List Connections, can the section be converted to an object?</li>
  </ol>