C# - Passing an anonymous function as a parameter <p>I'm using FluentData as an orm for my database and I'm trying to create a generic query method:</p> <pre><code>internal static T QueryObject&lt;T&gt;(string sql, object[] param, Func&lt;dynamic, T&gt; mapper) { return MyDb.Sql(sql, param).QueryNoAutoMap&lt;T&gt;(mapper).FirstOrDefault(); } </code></pre> <p>Except in my class's function:</p> <pre><code>public class MyDbObject { public int Id { get; set; } } public static MyDbObject mapper(dynamic row) { return new MyDbObject { Id = row.Id }; } public static MyDbObject GetDbObjectFromTable(int id) { string sql = @"SELECT Id FROM MyTable WHERE Id=@Id"; dynamic param = new {Id = id}; return Query&lt;MyDbObject&gt;(sql, param, mapper); } </code></pre> <p>at <code>Query&lt;MyDbObject&gt;(sql, param, mapper)</code> the compilers says:</p> <p><code>An anonymous function or method group connot be used as a constituent value of a dynamically bound object.</code></p> <p>Anyone have an idea of what this means?</p> <p>Edit:</p> <p>The compiler doesn't complain when I convert the method into a delegate:</p> <pre><code>public static Func&lt;dynamic, MyDbObject&gt; TableToMyDbObject = (row) =&gt; new MyDbObject { Id = row.Id } </code></pre> <p>It still begs the question of why one way is valid but not the other.</p>