Skip to content

Conversation

@linkdotnet
Copy link
Owner

No description provided.

@linkdotnet linkdotnet requested a review from Copilot April 30, 2025 19:30
Copy link

Copilot AI left a comment

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 upgrades the major MongoDB version and updates repository interfaces and implementations to enforce non-null selector parameters while broadening the query extension method to work with generic IQueryable instances.

  • Updated selector parameter to be non-nullable in repository methods
  • Adjusted the ToPagedListAsync extension to use IQueryable
  • Added pragma directives in the MongoDB connection provider to suppress disposal warnings

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/LinkDotNet.Blog.Infrastructure/Persistence/Sql/Repository.cs Updated selector parameter to non-nullable
src/LinkDotNet.Blog.Infrastructure/Persistence/RavenDb/Repository.cs Updated selector parameter to non-nullable
src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/Repository.cs Updated selector parameter to non-nullable and improved method chaining for readability
src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/PaginatedListQueryExtensions.cs Changed extension method signature from IMongoQueryable to IQueryable
src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/MongoDBConnectionProvider.cs Added pragma directives to suppress disposal warnings
src/LinkDotNet.Blog.Infrastructure/Persistence/IRepository.cs Updated selector parameter to non-nullable
src/LinkDotNet.Blog.Infrastructure/Persistence/CachedRepository.cs Updated selector parameter to non-nullable
Files not reviewed (1)
  • Directory.Packages.props: Language not supported
Comments suppressed due to low confidence (1)

src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/PaginatedListQueryExtensions.cs:10

  • Changing the extension method to accept IQueryable rather than IMongoQueryable broadens usage, but verify that MongoDB-specific query optimizations are not inadvertently affected.
public static async Task<IPagedList<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageIndex, int pageSize, CancellationToken token = default)

int page = 1,
int pageSize = int.MaxValue) =>
GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);

Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

The selector parameter is now non-nullable; ensure that all consumers of this repository pass a valid non-null selector expression.

Suggested change
/// <summary>
/// Retrieves a paginated list of entities projected to a specific type.
/// The selector parameter must not be null.
/// </summary>

Copilot uses AI. Check for mistakes.
bool descending = true,
int page = 1,
int pageSize = int.MaxValue) =>
GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

The selector parameter is now required; update any RavenDB repository calls to supply a non-null expression.

Suggested change
GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);
GetAllByProjectionAsync(selector: s => s, filter, orderBy, descending, page, pageSize);

Copilot uses AI. Check for mistakes.

public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
Expression<Func<TEntity, TProjection>>? selector,
Expression<Func<TEntity, TProjection>> selector,
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

The change to a non-nullable selector enforces that a valid projection is always provided; confirm that downstream callers are updated accordingly.

Copilot uses AI. Check for mistakes.

ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
Expression<Func<TEntity, TProjection>>? selector,
Expression<Func<TEntity, TProjection>> selector,
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

By removing the nullable annotation, the repository interface now requires a non-null selector; ensure that implementations and consumers are consistent with this change.

Suggested change
Expression<Func<TEntity, TProjection>> selector,
Expression<Func<TEntity, TProjection>> selector, // Must not be null

Copilot uses AI. Check for mistakes.

public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
Expression<Func<T, TProjection>>? selector,
Expression<Func<T, TProjection>> selector,
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

The updated non-nullable selector parameter mandates that a projection must always be provided; verify that cached calls conform to this requirement.

Copilot uses AI. Check for mistakes.
@linkdotnet linkdotnet merged commit 3f67611 into master Apr 30, 2025
3 checks passed
@linkdotnet linkdotnet deleted the mongo-upgrade branch April 30, 2025 19:32
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