是否有第 3 方库知道将 linq 表达式转换为人类可读的字符串表示形式?
我有一个 linq 表达式,我希望以人类可读的形式在日志中显示它。有人知道哪个图书馆可以做到这一点吗?我看到了这个条目从 lambda 表达式创建字符串,但它在我看来,没那么有用。
谢谢。
编辑
现在我想了一下,我的情况可能不具有代表性,因为我的 linq 表达式内部包含一个类型名称,它被 ToString 扩展为完全可怕的东西,因为该类型是泛型一。例如,表达式e => e.TypeName == typeof(T).AssemblyQualifiedName
其中 T 是我的通用上下文扩展为:
"e => (e.TypeName == \"Shunra.Infra.DummyEntity.Contract.IDummyEntity`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], Shunra.Infra.DummyEntity.Contract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=807fc02bc4ce69db\")"
看起来要求程序集限定名称的格式良好一点也不公平......
I have a linq expression and I wish to display it in the log in a human readable form. Any one knows any library that can do it? I saw this entry Creating a string from a lambda expression, but it is not that useful, in my opinion.
Thanks.
EDIT
Now that I think about it, my case is probably not that representative, because my linq expression includes a type name inside, which is expanded by the ToString to something totally monstrous, because the type is a generic one. For example, the expression e => e.TypeName == typeof(T).AssemblyQualifiedName
where T is my generic context is expanded to:
"e => (e.TypeName == \"Shunra.Infra.DummyEntity.Contract.IDummyEntity`1[[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], Shunra.Infra.DummyEntity.Contract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=807fc02bc4ce69db\")"
Looks like demanding that the assembly qualified name be nicely formatted is not fair at all...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以只使用
ToString
,输出是相当可读的,至少对于程序员来说......You can just use
ToString
, the output is fairly readable, at least to a programmer...