title: c# Action<T> How to handle with anonymous methods
body: <p>I've recently explored c# to myself. But stuck with this problem.</p>
  
  <p>So I have a method dbExec</p>
  
  <pre><code>public void dbExec(Action&lt;OleDbCommand&gt; func)
  {
      using (var conn = new OleDbConnection(connStr))
      {
          conn.Open();
          var cmd = conn.CreateCommand();
          func(cmd); 
      }
  }
  </code></pre>
  
  <p>delegate,</p>
  
  <pre><code>public delegate void DelCmd(OleDbCommand cmd);
  </code></pre>
  
  <p>and another method:</p>
  
  <pre><code>public ICollection&lt;string&gt; CheckUserPermissions() 
  {
      List&lt;string&gt; logins = new List&lt;string&gt;();
      DelCmd delCmd = delegate(OleDbCommand cmd)
      {
          cmd.CommandText = "SELECT PERMISSIONS.LOGIN FROM PERMISSIONS";
          using (var rdr = cmd.ExecuteReader()) while (rdr.Read()) logins.Add(rdr["LOGIN"].ToString());  
      };
      dbExec(delcmd);
      return logins;
  } 
  </code></pre>
  
  <p>The problem with <code>dbExec(delcmd);</code> statement. The error is "delcmd doesn't exist in current context". How to pass an anonymous method as a parameter to another method with Action declared parameter? </p>