Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace official MongoDB Driver #54

Open
Turnerj opened this issue Apr 2, 2019 · 7 comments
Open

Replace official MongoDB Driver #54

Turnerj opened this issue Apr 2, 2019 · 7 comments
Labels
affects-indexing Indexing-related issue affects-querying Query-related issue affects-serialization Serialization-related issue affects-writing Write-related issue enhancement Enhancements & features major-change Major changes required
Milestone

Comments

@Turnerj
Copy link
Member

Turnerj commented Apr 2, 2019

Due to the numerous issues with the driver which make working with it far harder than it needs to be and more limiting, this issue is for the eventual removal of the official MongoDB Driver with a custom implementation.

This does mean a large loss in feature compatibility between MongoFramework and the official driver however this may be a good thing. Removing the limitations of the driver allows for more advanced querying.

Some of the reasons for this change include:

The list of reasons here isn't exhaustive, just the ones that come to mind as I write this

Sure, a few of these things are just bugs in the MongoDB Driver and could be fixed but some are fundamental flaws with how the driver works.

This change is definitely not scheduled for Version 1 as it is a huge change - this issue is really just for putting it on the cards of things that need looking at in the future.

@Turnerj Turnerj added the enhancement Enhancements & features label May 22, 2019
@Turnerj Turnerj added this to the Future milestone Jul 9, 2019
@Turnerj Turnerj added affects-querying Query-related issue affects-indexing Indexing-related issue affects-serialization Serialization-related issue affects-writing Write-related issue major-change Major changes required labels Jul 9, 2019
@Turnerj
Copy link
Member Author

Turnerj commented Oct 29, 2019

Current status:

In addition to these, there would still need to be tasks for:

  • Low-level command writing (translating insert/update/replace etc to write queries - replacing the internals of what BulkWrite etc do - this would include writing indexes etc)
  • Replace connection core (all the lowest level communication to MongoDB)

@ahmednfwela
Copy link

This issue was opened in 2019, is this still relevant when we are almost 2023 ? or can this package depend on the official driver again ?

@Turnerj
Copy link
Member Author

Turnerj commented Nov 13, 2022

Hey @ahmednfwela - currently MongoFramework still does depend on the MongoDB Driver in a number of significant ways. That said, a number of the issues I've raised above still remain in the driver.

There is some movement for things to be better and more extendable including some major changes to their internal LINQ implementation (which I plan to utilise more heavily in future releases) however I'd still pursue moving more pieces out of the driver's hands and into MongoFramework where I can introduce more control and flexibility of behaviour.

@ahmednfwela
Copy link

Hey @Turnerj , thanks for the response.

Replacing the official driver is fine and all, but I have been running into conflicts trying to use the official driver LINQ and MongoFramework LINQ in the same file, I can't even use ToListAsync() on IMongoQueryable because the driver is using extensions on IQueryable as well

@Turnerj
Copy link
Member Author

Turnerj commented Nov 13, 2022

Yeah, extension conflicts from importing both MongoFramework.Linq and the driver's equivalent in the same file is definitely going to have problems. There isn't a lot I can really do about that with the biggest thing to help, having my LINQ extensions tucked behind their own namespace, is already in place versus having them in the global namespace.

One fairly average suggestion would be to split the class you're working in into separate files to avoid it - like a partial class. Then in one you can reference anything MongoFramework related and in the other, anything driver related. Obviously this breaks down quite a bit if it is a single method where you need both plus partial classes can get messy.

Out of curiousity, what were you needing to fall back to the driver for? Perhaps there is a way MongoFramework can cover it so you don't need to?

@Turnerj
Copy link
Member Author

Turnerj commented Nov 13, 2022

Oh, I should probably state, even if I wasn't going to replace the driver any more, those LINQ extensions are probably one of the areas that would remain regardless. To provide some of the functionality in MongoFramework, I have to wrap the driver in certain ways as many types and interfaces are internal to the driver.

@ahmednfwela
Copy link

Out of curiousity, what were you needing to fall back to the driver for? Perhaps there is a way MongoFramework can cover it so you don't need to?

I am migrating an old project from (MSSQL [EF core] + MongoDB) to MongoDB Only, and I was replacing EF core context with MongoFramework contexts, where I started facing this IQueryable conflict issue.

So I decided to build my own context class and use raw IMongoCollection instead.

I think that a simple solution to the conflicts would be to create a new Queryable type, e.g.: IMongoFrameworkQueryable<T> that extends IMongoQueryable<T> and build all the extensions on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-indexing Indexing-related issue affects-querying Query-related issue affects-serialization Serialization-related issue affects-writing Write-related issue enhancement Enhancements & features major-change Major changes required
Projects
None yet
Development

No branches or pull requests

2 participants