Search code examples
.netlinqlambdaexpression-treeshuman-readable

Is there a 3rd party library that knows to convert a linq expression to a human readable string representation?


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...


Solution

  • You can just use ToString, the output is fairly readable, at least to a programmer...