Skip to content

CSHARP-6144: Add public API to get the owning IMongoClient from a MongoDB LINQ queryable - #2093

Merged
adelinowona merged 1 commit into
mongodb:mainfrom
adelinowona:csharp6144
Aug 6, 2026
Merged

CSHARP-6144: Add public API to get the owning IMongoClient from a MongoDB LINQ queryable#2093
adelinowona merged 1 commit into
mongodb:mainfrom
adelinowona:csharp6144

Conversation

@adelinowona

Copy link
Copy Markdown
Contributor

No description provided.

@adelinowona
adelinowona requested a review from sanych-sun August 4, 2026 15:16
@adelinowona
adelinowona requested a review from a team as a code owner August 4, 2026 15:16
Copilot AI review requested due to automatic review settings August 4, 2026 15:16
@adelinowona adelinowona added the feature Adds new user-facing functionality. label Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR (CSHARP-6144) adds a new public LINQ extension API that allows consumers to retrieve the owning IMongoClient from a MongoDB LINQ IQueryable, by plumbing the client through the LINQ query provider.

Changes:

  • Added IQueryableExtensions.GetClient(this IQueryable source) as a public API entry point.
  • Extended the internal LINQ provider contract (IMongoQueryProviderInternal) and implementation (MongoQueryProvider) to expose an owning IMongoClient.
  • Added unit tests covering common queryable shapes (collection, projection, group join, database) and error cases.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/MongoDB.Driver.Tests/Linq/IQueryableExtensionsTests.cs Adds tests validating GetClient behavior across several LINQ queryable shapes and error paths.
src/MongoDB.Driver/Linq/Linq3Implementation/MongoQueryProvider.cs Exposes Client from the LINQ3 query provider implementation.
src/MongoDB.Driver/Linq/IQueryableExtensions.cs Introduces the new public GetClient extension method.
src/MongoDB.Driver/Linq/IMongoQueryProvider.cs Extends the internal query provider interface with a Client property.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

throw new ArgumentException("The source argument must be a MongoDB IQueryable.", nameof(source));
}

return provider.Client;

@sanych-sun sanych-sun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adelinowona
adelinowona merged commit 639ca6c into mongodb:main Aug 6, 2026
22 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adds new user-facing functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants