Created
September 14, 2011 15:39
-
-
Save amirci/1216901 to your computer and use it in GitHub Desktop.
Anonymous classes as parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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