Skip to content

♻️ refactor: extract shared EntityFrameworkUnitOfWork base (document providers) - #3

Merged
edgarmesquita merged 2 commits into
masterfrom
refactor/shared-unit-of-work
Jul 20, 2026
Merged

edgarmesquita merged 2 commits into
masterfrom
refactor/shared-unit-of-work

Conversation

@edgarmesquita

Copy link
Copy Markdown
Contributor

What

Extracts the store-agnostic IQueryableUnitOfWork boilerplate — repeated almost verbatim in the MongoDb (and incoming CosmosDb) unit of works — into an abstract EntityFrameworkUnitOfWork in the base package. Each document provider now overrides a single CreateSetCore<TEntity>() to build its own Set; MongoDb's unit of work drops from ~245 lines to ~15.

Why

The relational providers keep RelationalUnitOfWork as-is — it is also a raw-SQL executor (RelationalSqlExecutor), a separate concern, and uses different field names so it was never part of the duplication.

Verification

Behaviour-neutral. base / Relational / SqlServer / MongoDb build on net8 + net10; all 30 tests pass (base 9, SqlServer 18, MongoDb 3).

…document providers

The MongoDb and (incoming) CosmosDb unit of works were near-identical copies of the same ~200 lines of store-agnostic IQueryableUnitOfWork boilerplate (Commit, GetRepository, ApplyCurrentValues, LoadCollection, Dispose, ...). Extracts that into an abstract EntityFrameworkUnitOfWork in the base package, with a single abstract CreateSetCore<TEntity>() each provider overrides to build its own Set. MongoDb's unit of work drops to ~15 lines. The relational providers keep RelationalUnitOfWork (it also is a raw-SQL executor, a separate concern). Behaviour is unchanged; base/Relational/SqlServer/MongoDb build and all 30 tests pass.
…r the shared UnitOfWork

The base package gained the shared EntityFrameworkUnitOfWork (additive), so it must be republished for the document providers (which now derive from it) to resolve at runtime. MongoDb is bumped to publish its thinned unit of work. The relational providers are unchanged.
@edgarmesquita
edgarmesquita merged commit 8485c4b into master Jul 20, 2026
33 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants