Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update lambda expression documentation to clarify method call behavior in expression trees #47037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 30, 2025

The existing documentation made an overly absolute statement about method calls in expression trees, claiming that query providers "can't replicate the method's function" when they don't recognize a method call. This was inaccurate because many query providers can handle specific method calls by translating them appropriately.

Changes Made

Updated the documentation in docs/csharp/language-reference/operators/lambda-expressions.md to:

  1. Replace absolute language with conditional guidance: Changed from "Otherwise, the query provider can't replicate the method's function" to explaining that support depends on the provider's capabilities
  2. Add concrete example: Mentioned that SQL-based providers can translate String.StartsWith to LIKE expressions
  3. Improve accuracy: Used "you should limit method calls to those methods that the query provider can handle" instead of the previous phrasing

Before

However, when creating expression trees evaluated by a query provider, limit method calls to those methods recognized by the query provider. Otherwise, the query provider can't replicate the method's function.

After

However, when creating expression trees evaluated by a query provider, you should limit method calls to those methods that the query provider can handle. Different query providers have varying capabilities—for example, many SQL-based providers can translate methods like String.StartsWith into appropriate SQL expressions such as LIKE. If a query provider doesn't recognize a method call, it can't translate or execute the expression.

This change makes the documentation more accurate and helpful by acknowledging that method call support varies by provider rather than being universally impossible.

Fixes #13323.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/operators/lambda-expressions.md Lambda expressions and anonymous functions

@Copilot Copilot AI changed the title [WIP] Method calls can be used in expression trees, as long as the provider understands them Update lambda expression documentation to clarify method call behavior in expression trees Jun 30, 2025
@Copilot Copilot AI requested a review from BillWagner June 30, 2025 19:49
Copilot finished work on behalf of BillWagner June 30, 2025 19:49
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM, with one suggestion. I'll apply it and mark it ready for review.

@BillWagner BillWagner marked this pull request as ready for review July 1, 2025 16:28
@BillWagner BillWagner requested a review from a team as a code owner July 1, 2025 16:28
@BillWagner BillWagner requested a review from IEvangelist July 1, 2025 16:28
@BillWagner
Copy link
Member

@IEvangelist Can you review this one?

@BillWagner BillWagner enabled auto-merge (squash) July 1, 2025 16:29
@Copilot Copilot AI requested a review from BillWagner July 1, 2025 16:31
Copilot finished work on behalf of BillWagner July 1, 2025 16:31
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This LGTM now.

@BillWagner BillWagner merged commit 16a23f6 into main Jul 2, 2025
10 checks passed
@BillWagner BillWagner deleted the copilot/fix-13323 branch July 2, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method calls can be used in expression trees, as long as the provider understands them
3 participants