Debugging system.linq.dynamic RRS feed

  • Question

  • I have been trying to use a modified version of system.linq.dynamic to extract data from an anonymous type query result into a custom type that can be used elsewhere in my application.

    In doing so I have been following advice from this various places and posts, notably Scott Guthrie's blog and this forum. See for my previous posts and much helpful advice gratefully received.

    This advice directed me to a solution on Stack Overflow that proposed amending system.linq.dynamic, which I did as directed. It is a great solution and I hope I can get it to work. However, at this point, the amended code compiles but fails at run time at the following line in the key routine within system.linq.dynamic:

    bindings(i) = Expression.Bind(type.GetProperty(properties(i).Name), expressions(i))

    This is in the Expression Parser ParseNew method. The error message that I get reads: "Value cannot be null. Parameter name: member"

    I am trying to debug this but I having trouble determining what this error message actually means. As near as I can tell "member" is a parameter of the items held in expressions, which is a List(of Expression)(). Am I right?

    As far as I can tell, this line of code is trying to Bind the results of my query to the custom type. But I cannot tell whether properties() and expressions() are related to the custom type or the anonymous type? I think (but am by no means sure) that the properties() List holds references to the custom type properties. but what about expressions()?

    Until I can figure out what data is missing I am not clear on how to determine why it is missing. The missing data (ie a value for member) should be the name of one of the fields from the database returned by the query or one of the properties of the custom type. Correct? Or should it be the actual values of those fields from specific database records that meet the where clause criteria?

    BTW, the query itself works. When I break at runtime at look at the anonymous type, it holds the right data, I just can't get it into a useable form.

    There is more code and explanation in my post referred to above. Didn't want to repeat it all here.


    Tuesday, September 20, 2011 6:33 PM

All replies