title: How to run SQL Queries on EF?
body: <p>I am working on EF with C# and WPF as front end. I need to provide a UI for so user can create his own query and get the result. The UI will be list of tables and list of columns to select from (Not happy with UI. Need to improve but new ticks in my mind).</p>
  
  <p>So my question is how create, merge(existing query) and execute the queries.</p>
  
  <p>There are sql class Entity Client provider, objectquery class. I used ObjectQuery </p>
  
  <pre><code>string querystring = @"SELECT PrjDev FROM prjscenario"; 
  ObjectQuery&lt;PrjDev&gt; prjdevquery = new ObjectQuery&lt;PrjDev&gt;(querystring, ptxobjcontext);
  string cpmmandtext = prjdevquery.CommandText;
  int prjdevnum =  prjdevquery.Count();
  </code></pre>
  
  <p>It is working. But when i run some complex query. It is not working. Example code : </p>
  
  <pre><code>string querystring = @"SELECT PrjDev FROM prjscenario WHERE PrjDev.PrjDevType = 10";
  </code></pre>
  
  <p>Error :</p>
  
  <blockquote>
    <p>'PrjDevType' is not a member of
    'Transient.collection[Skm.Ptx.Data.Emf.PrjDev(Nullable=True,DefaultValue=)]'.
    To extract a property of a collection
    element, use a subquery to iterate
    over the collection. Near simple
    identifier, line 1, column 45.</p>
  </blockquote>
  
  <p>Any Idea, why it is good for one simple query but it is not working for complex queries?</p>
  
  <p>Thanks in Advance,
  N</p>