-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
While initially I thought it was best to separate the DbEntityReader and DbEntityWriter from the MongoDbSet, it doesn't seem as clear anymore to have this distinction.
For example, the DbEntityWriter really acts as an API that just gets in the way of calling the internal methods on the collection (InsertMany, DeleteMany etc). It also has code that references the DbEntityEntry class.
It does serve one nice purpose, it is how the mutation functionality is called but that could be restructured too.
What would be better is if there was something dedicated to converting the items in the DbChangeTracker into an IEnumerable<WriteModel<TEntity>>.
Besides I think more fitting for what I'm really trying to achieve here, it allows easier targeting of async against the MongoDb driver - specifically, it makes using the BulkWrite function a little easier.
To get here, I think a few things need to happen:
- Split the
IDbChangeTrackerinterface to have a lower level "container" where it has all but theDetectChangesmethod - Create a new
DbEntityWriteComposerclass, have that do the conversion from the items (through our new "container" interface) to theIEnumerable<WriteModel<TEntity>>data - Rip apart the
DbEntityWriterclass to just haveWriteandWriteAsyncfunctions which take the enumerable mentioned above - Change the
MongoDbSetclass to take the data from the "container" (implementation here is still the change tracker), use the "composer" and the re-writtenDbEntityWriterto push the changes to MongoDB
I still need to think about applying the mutation changes - where are they going to go?