I have an sproc which returns variable number of columns with different column names based on input parameter given to it. (and also number of rows >= 1)
For example, if input is 3, sproc returns 3 columns, and if input is 5, it returns 5. (Not sure on the input parameter that might be given)
I am using dapper to integrate my sproc in C# application and i am using dynamic as return type for it as below.
dynamic returnValue = connection.Query<dynamic>("sproc and inputs")
Can someone guide me on how to read the columns from dynamic variable?
Using returnValue[0].col1, returnValue[0].col2
works but i am not sure on the number of columns to query on.
Is there a way to read columns like returnValue[0]["c1"]
or any simpler way so that i can loop over to get all the columns based on input parameter?