Repository navigation
Document LINQ provider and EF Core translation suppression guidance for CA1847 (Fixes #48694) - #56681
Open
Manish-1kumar wants to merge 1 commit into
Conversation
Manish-1kumar
force-pushed
the
users/manish/issue-48694-ca1847-efcore-linq-suppression
branch
from
November 30, 2026 17:40
f17272d to
bbce70c
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The article’s ms.date remains 11/13/2026 and should be updated to reflect the substantive technical guidance added.
1 open issue
What changed in this PR
Updates CA1847 suppression guidance to address issue #48694 and explain LINQ provider translation limitations.
Changes:
- Adds guidance for EF Core and other LINQ providers that cannot translate
String.Contains(char)to SQL. - Explains the potential runtime exception and links to EF Core translation documentation.
| File | Description |
|---|---|
docs/fundamentals/code-analysis/quality-rules/ca1847.md |
Expands suppression guidance for database queries and adds an EF Core reference. |
Review effort: Balanced
| Suppress a violation of this rule if you're not concerned about the performance impact of the search invocation in question. | ||
| It's safe to suppress a violation of this rule if you're not concerned about the performance impact of the search invocation in question. | ||
|
|
||
| If you're using Entity Framework Core (EF Core) or other LINQ providers, you should suppress this rule for scenarios where you query a database using `string.Contains(string)` in an expression tree. Some LINQ providers cannot translate <xref:System.String.Contains(System.Char)?displayProperty=nameWithType> to SQL, throwing an <xref:System.InvalidOperationException> at run time. For more information, see [Translation of built-in .NET string operations](/ef/core/miscellaneous/collations-and-case-sensitivity#translation-of-built-in-net-string-operations). |
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.

Summary
Addresses issue #48694 by updating the
When to suppress warningsguidance in CA1847 (Use String.Contains(char) instead of String.Contains(string) with single characters):String.Contains(char)and throw anInvalidOperationExceptionat run time, making suppression of CA1847 appropriate in LINQ query contexts.Fixes #48694.
Internal previews
Build report