title: Disable CAST AS to optimize query in Entity Framework
body: <p>I'm using <em>Entity Framework 5</em> and I want to select data from <em>Oracle 10g</em> database.
  Problem is that the database table is huge and the query generated by <em>Entity Framework</em> is ineffective. I want to get rid of those <code>CAST( [column] AS [type] )</code>. Is there any setting to turn them off?</p>
  
  <p>C# code:</p>
  
  <pre><code>var context = new APPDB();
  var q = context.APP_TABLE.Where(i =&gt; i.ID == 123);
  
  // This is how I did get the generated SQL query
  var str = ((System.Data.Objects.ObjectQuery) q ).ToTraceString();
  </code></pre>
  
  <p>The generated query:</p>
  
  <pre><code>SELECT 
   CAST( "Extent1"."ID" AS number(10,0)) AS "C1", 
  "Extent1"."DESCRIPTION" AS "DESCRIPTION"
  FROM "APP"."APP_TABLE" "Extent1"
  WHERE (123 = ( CAST( "Extent1"."ID" AS number(10,0))))
  </code></pre>
  
  <p>What I want is the code to generate better performing query:</p>
  
  <pre><code>SELECT 
  "Extent1"."ID" AS "C1", 
  "Extent1"."DESCRIPTION" AS "DESCRIPTION"
  FROM "APP"."APP_TABLE" "Extent1"
  WHERE
  "Extent1"."ID" = 123
  </code></pre>