isn't reference to class C in collection.AsQueryable<C>() redundant?

26 views
Skip to first unread message

Andrew Heard

unread,
Apr 11, 2012, 12:32:34 AM4/11/12
to mongodb...@googlegroups.com
Why is it necessary to "templatize" the collection with method AsQueryable<C>() when the FluentMongo module was able to get by without this redundant reference to the collections class?

With FluentMongo I would have for example

private MongoCollection<C> _col;
foreach (var c in _col.AsQueryable()) {}

Whereas for MongoDB 1.4 I now have specify a redundant <C> in AsQueryable(),  for example:

private MongoCollection<C> _col;
foreach (var c in _col.AsQueryable<C>()) {}

thanks in advance for any replies, Andrew

Robert Stam

unread,
Apr 11, 2012, 9:59:03 AM4/11/12
to mongodb...@googlegroups.com
The reason it was done that way is that MongoDB is a schema free database and a single collection can contain more than one kind of document. However, it is also common for a single collection to contain only one kind of document, so your request also makes sense.

I created a JIRA ticket for this:


The JIRA ticket contains a bit of additional information.
Reply all
Reply to author
Forward
0 new messages