title: ExecuteScalar() analogue in custom Linq to Sql query
body: <p>I need to execute a custom sql query that i cannot do with regular L2S means:</p>
  
  <pre><code>select [row_number] from (select row_number() over (order by CreatedOn desc, ID desc) as [row_number], ID from MyTable) as T1 where ID = {0}
  </code></pre>
  
  <p>so i'm trying </p>
  
  <pre><code>var r = db.ExecuteQuery&lt;int&gt;(q, id).Single();
  </code></pre>
  
  <p>but that doesn't work (getting System.InvalidCastException: Specified cast is not valid). Any suggestions?</p>