Short form: My question is similar to this other stackoverflow answer, except that I need the Type of 'dynamic' rather than string etc
Dynamically create an array of Type in C#
Basically, I'm running a query using Dapper, which supports object mapping up to 7 objects -- I need 8.
When doing 7 it looks like:
connection.Query<dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic, dynamic>(sql, (obj1, obj2, obj3, obj4, obj5, obj6, obj7) => {...});
When doing 8 it's supposed to be:
connection.Query<dynamic>(sql, Type[], (objArray) => {...});
Where Type[] is an array of types -- in this case, 8 dynamic types.
I've tried all sorts of things from
var types = new Type[]{
dynamic,
dynamic,
dynamic,
dynamic,
dynamic,
dynamic,
dynamic,
dynamic
}
to
var types = new Type[]{
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject"),
Type.GetType("System.Dynamic.DynamicObject")
}
And various others. None of which works.
I'm figuring since 'dynamic' is rather the absence of a type, that maybe I'm approaching this slightly wrong?
Anyway, any ideas?
IDbConnection.Query? This must be an extension method since the interface defines no such method, but from where? What technology are you using? Or is your problem that you want to write such a method?dynamicis not a type - is just means that any binding will be done at run-time based on the actual type of the object. Can you add more about what you're trying to do?