✨ Add Azure Cosmos DB provider (eQuantic.Core.Data.EntityFramework.CosmosDb) - #2
Merged
Merged
Conversation
New non-relational EF Core provider for Azure Cosmos DB, mirroring the MongoDb provider. The Set overrides the four bulk operations via load-then-modify through the DbContext (Cosmos has no ExecuteDelete/ExecuteUpdate); UpdateMany extracts the assigned members from the update expression and evaluates each value against the loaded entity (so x.Count + 1 works) and touches only those members. Adds a QueryOptions.WithPartitionKey extension (single string on net8/net10, plus 2- and 3-level hierarchical keys on net10). Per-major packages 8.2.0 (EF Cosmos 8.0.29) and 10.1.0 (EF Cosmos 10.0.10); base InternalsVisibleTo extended to the new assembly. Registered in the solution and the ci.yml/release.yml matrices (14 build / 4 test). 10 unit tests (setter extraction, the four bulk ops via EF in-memory, WithPartitionKey wiring).
Adds a Why (the motivation the core-data README leads with) and a self-contained Getting started (install → entity/context/unit-of-work → registration → first query), so a reader can wire the provider up without leaving the README; folds the old Install section in. Fixes the intro to list Azure Cosmos DB alongside the other providers. Repository.md §7 now notes that set-based DeleteMany/UpdateMany run as server-side statements only on the relational providers — MongoDB uses its native driver and Cosmos DB loads-then-modifies. Marks docs/IMPROVEMENT_PLAN.md as historical/completed so it is not mistaken for the current design.
…ameworkUnitOfWork Now that the shared EntityFrameworkUnitOfWork lives in the base package, the Cosmos unit of work drops to overriding CreateSetCore only (removing the duplicated ~200-line copy that SonarCloud flagged). Bumps CosmosDb to 8.3.0/10.2.0 to line up with the base (4.6.0) it now depends on.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Adds a new non-relational EF Core provider —
eQuantic.Core.Data.EntityFramework.CosmosDb— forAzure Cosmos DB, mirroring the existing
MongoDbprovider and slotting into the v5 family (per-major8.x/10.x packaging).
Design
Cosmos via EF Core is a document store, so the provider builds on the base (not
Relational) and onlyoverrides the four bulk operations Cosmos can't do server-side (
ExecuteDelete/ExecuteUpdatearerelational-only):
DeleteMany/DeleteManyAsync— load the matching documents,RemoveRange+SaveChanges; returnthe matched count.
UpdateMany/UpdateManyAsync— extract the assigned members from thex => new T { … }expression,load the matches, and apply only those members to each (each value evaluated against the loaded
entity, so
x.Count + 1works). Unassigned fields are left intact.Everything else (Find/Insert/Execute, the
QueryOptions → IQueryabletranslation) is inherited fromSetBase.Partition keys
A Cosmos-specific
QueryOptionsextension so a read targets one logical partition instead of across-partition scan:
WithPartitionKey(string)is available on both net8 and net10; the 2- and 3-level hierarchical overloadsare net10-only (EF Cosmos 8 has no hierarchical API).
Packaging
across lines, consistent with the family.
InternalsVisibleToextended to the new assembly (the set reaches the base's internalDbSet).ci.yml/release.ymlmatrices (14 build / 4 test).Tests (10, all green)
CosmosUpdateExpressionsetter extraction — constant + entity-referencing values; rejectsnon-member-init / null.
UpdateManyleaves unassignedmembers intact.
WithPartitionKeyregisters a before-customization and chains.