Retrieving all BsonClassMaps

34 views
Skip to first unread message

Alex Brown

unread,
Sep 13, 2012, 9:57:24 AM9/13/12
to mongodb...@googlegroups.com
Is there a way of getting back a collection of all currently mapped types?

I've forked the repo, and submitted a patch to enable me to do this easily:

However, in the meantime, is there a way of doing this?

craiggwilson

unread,
Sep 13, 2012, 10:03:29 AM9/13/12
to mongodb...@googlegroups.com
No, there is not a way to do this.  May I ask why you need this functionality?

Alex Brown

unread,
Sep 13, 2012, 10:07:39 AM9/13/12
to mongodb...@googlegroups.com
Didn't think so. At least i wasn't going mad.

Easiest way to describe it is creating a kind of web api

request comes in as /customer/find-all

Rather than strong typing each of my services, i want a "base" service to handle them

so, "customer" is the type
We then look in our AllClassMaps collection, for a type, where name is "customer"

Can then instantiate the according repository, based on the retrieved Type from AllClassMaps

Hope that makes sense....

craiggwilson

unread,
Sep 13, 2012, 2:23:44 PM9/13/12
to mongodb...@googlegroups.com
Have you considered odata for this?  

Otherwise, the class maps listing is going to contain a number of classes that you might not want...  For instance, there is a class map for System.Object.  Hence, you'd somehow need to provide a filter to limit it to valid types.  Once you get there, you might as well just keep a list of all the support types or do some assembly level reflection for all types in a given namespace or implementing a particular interface.

Alex Brown

unread,
Oct 23, 2012, 4:27:51 AM10/23/12
to mongodb...@googlegroups.com
It would be much easier to have the list of mapped classes available.

ie: get the types via reflection
Then assert they are in BsonClassMap.AllClassMaps

OData wouldn't be appropriate for this

Currently, I'm iterating over the types retrieved by reflection, and doing a BsonClassMap.IsClassMapRegistered on each type...
Not very performant!
Reply all
Reply to author
Forward
0 new messages