title: DB Select within a class in WebMatrix
body: <p>I've coded a class which uses connection to the WebMatrix database. I can greatly do insert, update queries, but I have an issue with select queries. 
  I can't assign the Razor <strong>dynamic</strong> variable to my type-specified variable.</p>
  
  <p>How to use the WebMatrix database in an usual c# class?</p>
  
  <p>My code from the class:</p>
  
  <pre><code>    public bool verify_session()
      {
          if (get_user_id() &gt; 0)
      {
          return true;
      }
  
          if (HttpContext.Current.Request.Cookies["session_id"] != null)
      {
          var db = Database.Open("studia_sesje");
          var data = db.QuerySingle("SELECT session_id, user_id FROM sessions WHERE session_id = '" + HttpContext.Current.Request.Cookies["session_id"] + "'");
  
          _session_id = (string)data.session_id;
          _user_id = (int)data.user_id;
  
          return true;
      }
  
      return false;
      }
  </code></pre>
  
  <p>the error is</p>
  
  <blockquote>
    <p>Cannot perform runtime binding on a null reference</p>
  </blockquote>