user143887
user143887

Reputation:

Get properties from a dynamic type

i have a dynamic type

var f = context.ExecuteStoreQuery<dynamic>("CALL iv_sp_computersbyday();

how i can now what properties have the dynamic tuype returned??? i cant acces by reflection on the dynamic.

Upvotes: 6

Views: 2000

Answers (1)

jbtule
jbtule

Reputation: 31809

I'm not familiar with ExecuteStoreQuery but there is a difference between using the dynamic keyword and the object actually being a Dynamic Object. If it's a static object that is just cast as dynamic, then reflection will work just fine. If it's a Dynamic Object then reflection will return methods just not the ones you'd be expecting. Generally a Dynamic Object will have some way to query the parameters that are used to handle the implementation, for example things that inherit from DynamicObject often implement GetDynamicMemberNames and then has methods to invoke dynamically like TryGetMember. There are more general ways to do the dynamic binding once you have member names but it can be a little much to use with the DLR CallSites and Binders, although there are some simple static methods that encapsulate all the DLR stuff in the open source framework Impromptu-Interface.

Upvotes: 1

Related Questions