public virtual IList <string> GetCustomerNameByCountryAndCityWithAllDelegates(string country, string city) { IDbParametersBuilder builder = CreateDbParametersBuilder(); builder.Create().Name("Country").Type(DbType.String).Size(15).Value(country); builder.Create().Name("City").Type(DbType.String).Size(15).Value(city); ResultSetExtractorDelegate <IList <string> > extractorDelegate = delegate(IDataReader reader) { IList <string> customerList = new List <string>(); while (reader.Read()) { string contactName = reader.GetString(0); customerList.Add(contactName); } return(customerList); }; CommandSetterDelegate commandSetterDelegate = delegate(IDbCommand dbCommand) { //Down cast to SqlCommand or other provider to access provider specific functionality.... //In this case just use the general IDbCommand API. IDbDataParameter countryParameter = dbCommand.CreateParameter(); countryParameter.ParameterName = "@Country"; countryParameter.DbType = DbType.String; countryParameter.Value = country; IDbDataParameter cityParameter = dbCommand.CreateParameter(); cityParameter.ParameterName = "@City"; cityParameter.DbType = DbType.String; cityParameter.Value = city; dbCommand.Parameters.Add(countryParameter); dbCommand.Parameters.Add(cityParameter); }; //TODO compiler can't determine matching method if two anonymous methods are used within method parameters. // how to 'cast' the anonymous delegate? return(AdoTemplate.QueryWithResultSetExtractorDelegate(CommandType.Text, customerByCountryAndCityCommandText, extractorDelegate, commandSetterDelegate)); }