title: How to pass parameters to DbSet.SqlQuery Method in Entity Framework
body: <p>I am trying to execute a RAW SQL statement in Entity Framework which takes some parameters. The method I am using is from <a href="http://msdn.microsoft.com/en-us/library/system.data.entity.dbset.sqlquery(v=vs.103).aspx">DbSet.SqlQuery</a></p>
  
  <p>I am confused on how to construct the params object array:  params object[] parameters</p>
  
  <p>This is my code block here:</p>
  
  <pre><code>public ActionResult APILocation(string lat, string lng)
   {
      string SQL = "select * from (select Distance = ((ACOS(SIN(@lat * PI() / 180) * SIN(lat * PI() / 180) + COS(@lat * PI() / 180) * COS(lat * PI() / 180) * COS((@lng - Long) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) from dbo.Stores) t where  Distance &lt; 10 order by Distance asc";
              ObjectParameter latParam = new ObjectParameter("lat", lat);
              ObjectParameter lngParam = new ObjectParameter("lng", lng);
  
              object[] parameters = new object[] { latParam, lngParam };
  
              var stores = db.Stores.SqlQuery(SQL, parameters);
  
              return Json(stores, JsonRequestBehavior.AllowGet);
          } 
  </code></pre>
  
  <p>I tried creating ObjectParameter and putting it into an object array but that did not work.  Can someone provide an example on how I should construct the params object[] parameters</p>
  
  <p>Thanks!
  Flea</p>