Skip to content

Instantly share code, notes, and snippets.

@amirci
Created September 14, 2011 15:39
Show Gist options
  • Save amirci/1216901 to your computer and use it in GitHub Desktop.
Save amirci/1216901 to your computer and use it in GitHub Desktop.
Anonymous classes as parameters
// using a IDictionary
public void ExecuteCall(string query, IDictionary<string, object> parameters);
ExecuteCall("SELECT * from....", new Dictionary { {"City", "New York" }, { "Code", 3 } });
// using an anonymous
public void ExecuteCall(string query, object parameters);
// and to call it
ExecuteCall("SELECT * from....", new { City = "New York", Code = 3 } );
// and to use the parameters using reflection
parmeters.GetType().GetProperties().....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment