从动态类型获取属性

发布于 2024-09-30 12:40:33 字数 169 浏览 0 评论 0原文

我有一个动态类型

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

,我现在如何知道动态 tuype 返回了哪些属性???我无法通过动态反思来访问。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2024-10-07 12:40:33

我不熟悉 ExecuteStoreQuery 但使用动态关键字和对象实际上是动态对象之间有区别。如果它是一个静态对象,只是转换为动态对象,那么反射就可以正常工作。如果它是动态对象,那么反射将返回方法,而不是您期望的方法。通常,动态对象将有某种方法来查询用于处理实现的参数,例如,从 DynamicObject 继承的事物通常实现 GetDynamicMemberNames,然后具有调用方法像 TryGetMember 一样动态地进行。一旦有了成员名称,就有更通用的方法来执行动态绑定,但与 DLR CallSites 和 Binder 一起使用可能有点麻烦,尽管有一些简单的静态方法将所有 DLR 内容封装在开源框架中< a href="http://code.google.com/p/impromptu-interface/" rel="nofollow">即席界面。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文