title: How to query (using LINQ) FormattedValues in Dynamics CRM 2011
body: <p>I am using LINQ to retrieve Account type entities from Microsoft Dynamics CRM Online. I am unable to filter the list for a particular formatted value. I have the correct value, but am receiving zero records. 
  I'm creating my connection like this:</p>
  
  <pre><code>var connection = new CrmConnection("CRMOnline");
  connection.ProxyTypesEnabled = true;
  CrmOrganizationServiceContext _context = new CrmOrganizationServiceContext(connection);
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>List&lt;Account&gt; items = _context.CreateQuery&lt;Account&gt;()
                                .Where( c =&gt; ((OptionSetValue)c["new_accreditationstatus"]).Equals(7))
                                .ToList();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>List&lt;Account&gt; items = _context.CreateQuery&lt;Account&gt;()
                                .Where( c =&gt; c.GetFormattedAttributeValue("new_accreditationstatus") == "7"
                                .ToList();
  </code></pre>
  
  <p>and </p>
  
  <pre><code>List&lt;Account&gt; items = _context.CreateQuery&lt;Account&gt;()
                                .Where( c =&gt; c["new_accreditationstatus"] == "7"
                                .ToList();
  </code></pre>
  
  <p>The last on throws a System.Format exception.</p>
  
  <p>Filters on normal properties, i.e. <code>.Where(c =&gt; c.AccountNumber.StartsWith("2010"))</code> work perfectly fine.</p>