shanielh / MongoToLINQ

Parses Mongo where clauses to Expression trees
1 stars 1 forks source link

Support for querying runtime types #1

Open darkl opened 10 years ago

darkl commented 10 years ago

I'm opening the following issues for myself, so I'll be able to recall them in the future.

I'd like to be able to query the actual objects: sometimes I don't know in advance what will be the type of the queried object, or one of its properties, has for instance an interface type, but the actual property has, of course, a concrete type which might have more properties to query.

I know this doesn't allow expression tree creation, but I'm more interested in functionality than in performance.

shanielh commented 10 years ago

That seems to be supported in MongoToLINQ. The QueryParser c'tor receives the runtime type as the first argument.

darkl commented 10 years ago

This solves only the first problem.

The second problem I mentioned is when the root object is an instance of a class that has a property of abstract type Shape. Assume Circle derives from Shape and adds a property named Radius. Now I want to query all objects that their Shape property has a Radius that is greater than 3. I think it won't work since the built expression uses only the property type and not the runtime type.

I know this doesn't seem like the right C# behavior, but I think it is closer to the Mongo behavior (where objects are schema less).