Is there anyway to execute this Expression and get the actual value not as object?

青春壹個敷衍的年華 提交于 2019-12-13 03:45:00

问题


Given an Expression that returns a IQueryable<sometype>. If I don't know what sometype is at compile-time. Can I somehow execute the Expression and get IQueryable<actual type> returned.

Obviously I can use,

Expression.Lambda<Func<object>>(expressionInstance).Compile()()

But of course I'll get an object back. Or, I can use,

Expression.Lambda<Func<IQueryable>>(expressionInstance).Compile()()

But I'll get back a IQueryable which is of no use if I want to actually use any extension methods such as select, etc., I'll still need IQueryable<actual type>.

来源:https://stackoverflow.com/questions/55056318/is-there-anyway-to-execute-this-expression-and-get-the-actual-value-not-as-objec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!