mfenniak / rethinkdb-net

A C# / .NET client driver for RethinkDB.
Other
247 stars 37 forks source link

Can't access members of objects other than the function parameter #209

Closed mfenniak closed 9 years ago

mfenniak commented 9 years ago

Some attempts to access a member of an object in a LINQ expression tree, other than the parameter, don't work. In particular, using the new regex match operator from #107 and then accessing fields on the result don't work. This seems to be caused by BaseExpression.cs only supporting static members, not any random expression type for which a IObjectDatumConverter is available.

First attempt to fix this caused an issue where anonymous types that could & should be evaluated client-side are turning into server-side serialized objects. In particular, variables referenced from the function scope by a delegate. Was able to address this with a hack in the AnonymousTypeDatumConverterFactory, but that doesn't fix the same problem on the newtonsoft converters.

Was able to address the problem in the first approach by identifying that the expression nodes referenced a constant, and using client-side conversion for the constants. The hack disappeared, tests passed. Fixed up some code duplication and this PR is good to go.