Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Jun 13, 2025

It addresses the issue #506

@fiseni fiseni requested a review from Copilot June 13, 2025 09:01
Copy link

@Copilot 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 refactors the state management for include expressions and include strings to use the OneOrMany generic type, addressing issue #506. Key changes include refactoring Specification.cs to use OneOrMany for include state, updating the IncludeEvaluator and IncludeStringEvaluator to handle the new state, and adding tests for include scenarios.

Reviewed Changes

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

Show a summary per file
File Description
tests/Ardalis.Specification.EntityFrameworkCore.Tests/Evaluators/IncludeStringEvaluatorTests.cs Added a test to verify query behavior when no include string is provided.
tests/Ardalis.Specification.EntityFrameworkCore.Tests/Evaluators/IncludeEvaluatorTests.cs Added tests to verify behavior for specs with no or a single include expression.
src/Ardalis.Specification/Specification.cs Refactored include state from List to OneOrMany, updating add and copy functionality.
src/Ardalis.Specification.EntityFrameworkCore/Evaluators/IncludeStringEvaluator.cs Updated evaluator to check OneOrMany include strings for optimized processing.
src/Ardalis.Specification.EntityFrameworkCore/Evaluators/IncludeEvaluator.cs Updated evaluator to check OneOrMany include expressions and use caching for delegates.
Comments suppressed due to low confidence (2)

src/Ardalis.Specification.EntityFrameworkCore/Evaluators/IncludeStringEvaluator.cs:16

  • [nitpick] Ensure that the SingleOrDefault property on OneOrMany returns null when there are multiple elements so that the fallback loop is reliably executed. If not already documented, please clarify this behavior in the OneOrMany API documentation.
if (spec.OneOrManyIncludeStrings.SingleOrDefault is { } includeString)

src/Ardalis.Specification.EntityFrameworkCore/Evaluators/IncludeEvaluator.cs:46

  • [nitpick] Confirm that the SingleOrDefault property on OneOrMany returns null when more than one include expression is present so that the subsequent iteration over IncludeExpressions properly handles multiple items. Consider documenting this behavior for future maintainers.
if (spec.OneOrManyIncludeExpressions.SingleOrDefault is { } includeExpression)

@fiseni fiseni merged commit 50ec01a into main Jun 13, 2025
1 check passed
@fiseni fiseni deleted the fiseni/oneormany-include branch June 13, 2025 09:03
@fiseni fiseni linked an issue Jun 13, 2025 that may be closed by this pull request
This was referenced Aug 20, 2025
This was referenced Oct 1, 2025
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.

Use OneOrMany for all internal collections
1 participant