serialize dictionary with Json.net and select query on entity
<p>I have code that looks like this...                </p>

<pre><code>var records = from part in this.DataWorkspace.AUTOData.TestParameterViews
    select new
      {Name = part.ParamName, Val = part.CurrentValue}     

File.WriteAllText(@"c:\params.json", JsonConvert.SerializeObject(new{parameters = records }, Formatting.Indented));
</code></pre>

<p>The generated json file looks like this.....</p>

<pre><code>{
 "parameters": [
 {
   "Name": "Var1",
   "Val": 6666.0
 },
 {
   "Name": "Var2",
   "Val": 1.0
 },
 {
   "Name": "Var3",
   "Val": 5500.0
 },
</code></pre>

<p>And so on...listing all the members within the entity. </p>

<p>PROBLEM:  I would like the json output to be in a dictionary format (shown below), but still query the entity.  </p>

<pre><code>"parameters": {
    "Var1": 6666.0,
    "Var2": 1.0,
    "Var3": 5500.0,
</code></pre>

<p>I have tried the following code but am hung up on syntax.  Specifically Intellisense is indicating an error on the <code>select</code> saying "Cannot implicitly convert type....An explicit conversion exists(are you missing a cast?)  </p>

<pre><code>Dictionary&lt;string, float&gt; records = from part in this.DataWorkspace.AUTOData.TestParameterViews
        select new Dictionary&lt;string, float&gt;
      {Name = part.ParamName, Val = part.CurrentValue}     

File.WriteAllText(@"c:\params.json", JsonConvert.SerializeObject(new{parameters = records }, Formatting.Indented));
</code></pre>

<p>Thanks for your help!</p>