This project has moved. For the latest updates, please go here.

Make IRepository be IQueryable

Dec 5, 2012 at 5:40 PM

I've noticed that you have methods that expose parts of IQueryable<>. Why not just have IRepository<> implement IQueryable<>?

Coordinator
Dec 5, 2012 at 5:49 PM

Because MongoRepository wouldn't be much of a repository implementation anymore? You'd be better off just using the ngen mongocsharpdriver directly. Or am I understanding the question wrong?

Dec 6, 2012 at 4:04 PM
The reason I ask is that you are implementing All(), GetSingle(), when if you made IRepository<T> look like:

IRepository<T> : IQueryable<T>

Then in MongoRepository<T> you would just implement the 4 IQueryable methods by basically just returning the equivalent method on the MongoCollection, then you could just do mongoRepo.Where() or mongoRepo.First(), etc. You could still have all your other repo pattern specific methods such as Add, Update, and Delete, but this would make the repo object directly queryable.

I just thought I'd throw out an idea.



On Wed, Dec 5, 2012 at 10:49 AM, RobIII <notifications@codeplex.com> wrote:

From: RobIII

Because MongoRepository wouldn't be much of a repository implementation anymore? You'd be better off just using the ngen mongocsharpdriver directly. Or am I understanding the question wrong?

Read the full discussion online.

To add a post to this discussion, reply to this email (MongoRepository@discussions.codeplex.com)

To start a new discussion for this project, email MongoRepository@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com


Coordinator
Dec 6, 2012 at 5:43 PM
Edited Dec 6, 2012 at 6:00 PM

>>I just thought I'd throw out an idea.

Don't get me wrong, your input is appreciated! :)

And you might be right; this sounds like a good idea (although we'd have to keep All() and GetSingle() in for a while and mark them obsoleted to not break backwards compatibility for some time). I'll consider this option but let it sink in for a while weiging pro's / cons. (Interesting posts/discussions here and here for example). I do have some reservations I might need to overcome first :P

More input (either pro or con) is appreciated!

May 12, 2013 at 1:38 AM
I was just about to make the same suggestion to have IRepository<T> : IQueryable<T>. Rob, will you be following up on this? I'm happy to submit a patch.
Coordinator
May 13, 2013 at 8:03 AM
See Changeset 26210. I'd love to hear C&C.