Click here to Skip to main content
15,887,363 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a stored procedure that always returns a list of strings. However, based on the parameters passed to the stored procedure, the column heading for the list of strings will change. Is Dapper able to handle this? If so, how should it be handled?

I don't really care about the column header, I want to access the list of strings, but I don't know how to reference the data since the column header changes.

Current non-functional code:

C#
conn.Open();
var p = new DynamicParameters();
p.Add("Search_Function_CD", searchFunction, DbType.String, ParameterDirection.Input);
p.Add("Search_Value", searchValue, DbType.String, direction: ParameterDirection.Input);
p.Add("o_resultset", dbType: DbType.Object, direction: ParameterDirection.Output);
var Results = (IDictionary<string, object>)conn.Query(sql: CommonConstants.ProcedureConstants.PKG_GET_SEARCH_RESULTS, param: p, commandType: CommandType.StoredProcedure);
foreach (object o in Results)
{
	string element = Results.Values.ElementAt(1) as string;
	searchResults.Add(element);
}
conn.Close();
return searchResults;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900