title: What goes in the params parameter of the .SqlQuery() method in Entity Framework?
body: <p>The method takes a string for the query, and an array of <code>Object []</code> for the parameters, presumably to avoid SQL Injection.</p>
  
  <p>However nowhere on earth is it documented what you should put into the object array.</p>
  
  <p>There is another question on SO that asks this exact same thing, but the accepted answer doesn't work: <a href="https://stackoverflow.com/questions/12925649/when-using-dbsett-sqlquery-how-to-use-named-parameters">When using DbSet&lt;T&gt;.SqlQuery(), how to use named parameters?</a></p>
  
  <p>I've tried all forms of parameter replacement I can think of and all of them throw an exception. Any ideas?</p>
  
  <p>Would that it were as simple as:</p>
  
  <p><code>SqlQuery("SELECT * FROM @table", "Users")</code></p>
  
  <p>Edit: Here are some things I've tried (Exception is an <code>SqlException</code>):</p>
  
  <pre><code>    var result = context.Users.SqlQuery&lt;T&gt;("SELECT * FROM @p0 WHERE @p1 = '@p2'", 
  new SqlParameter("p0", tableName), 
  new SqlParameter("p1", propertyName), 
  new SqlParameter("p2", searchQuery));
  </code></pre>
  
  <p>This gives <code>Must declare the table variable "@p0".</code></p>
  
  <pre><code>var result = context.Users.SqlQuery&lt;T&gt;("SELECT * FROM {0} WHERE {1} = '{2}'", tableName, propertyName, searchQuery);
  </code></pre>
  
  <p>This gives <code>Must declare the table variable "@p0".</code></p>