From 536035e7e0955855e551b204c007dbecc7c45cd8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:41:05 +0000 Subject: [PATCH 1/6] Initial plan From fb46d06043f87507a52428869ad1eee567b40984 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:44:39 +0000 Subject: [PATCH 2/6] Document TagWithCallSite method in Query Tags documentation Co-authored-by: roji <1862641+roji@users.noreply.github.com> --- entity-framework/core/querying/tags.md | 32 ++++++++++++++++++++++++++ samples/core/Querying/Tags/Program.cs | 20 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/entity-framework/core/querying/tags.md b/entity-framework/core/querying/tags.md index b701b6c02c..5baf28da20 100644 --- a/entity-framework/core/querying/tags.md +++ b/entity-framework/core/querying/tags.md @@ -68,6 +68,38 @@ FROM [People] AS [p] ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC ``` +## Tagging with file name and line number + +Starting with EF Core 6.0, queries can be automatically tagged with the file name and line number where the LINQ query is defined in source code. This is done using the `TagWithCallSite()` method: + +[!code-csharp[Main](../../../samples/core/Querying/Tags/Program.cs#TagWithCallSite)] + +This query translates to: + +```sql +-- file: ...\samples\core\Querying\Tags\Program.cs:49 + +SELECT TOP(@__p_1) [p].[Id], [p].[Location] +FROM [People] AS [p] +ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC +``` + +The `TagWithCallSite()` method can be combined with `TagWith()` to provide both custom tags and call site information: + +[!code-csharp[Main](../../../samples/core/Querying/Tags/Program.cs#TagWithCallSiteAndTag)] + +This produces: + +```sql +-- GetClosestPeople + +-- file: ...\samples\core\Querying\Tags\Program.cs:57 + +SELECT TOP(@__p_1) [p].[Id], [p].[Location] +FROM [People] AS [p] +ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC +``` + ## Known limitations **Query tags aren't parameterizable:** diff --git a/samples/core/Querying/Tags/Program.cs b/samples/core/Querying/Tags/Program.cs index a376d7db13..d19070c0b1 100644 --- a/samples/core/Querying/Tags/Program.cs +++ b/samples/core/Querying/Tags/Program.cs @@ -40,6 +40,26 @@ orderby f.Location.Distance(myLocation) descending string").ToListAsync(); #endregion } + + using (var context = new SpatialContext()) + { + #region TagWithCallSite + var myLocation = new Point(1, 2); + var closestPeople = await (from f in context.People.TagWithCallSite() + orderby f.Location.Distance(myLocation) descending + select f).Take(5).ToListAsync(); + #endregion + } + + using (var context = new SpatialContext()) + { + #region TagWithCallSiteAndTag + var myLocation = new Point(1, 2); + var closestPeople = await (from f in context.People.TagWith("GetClosestPeople").TagWithCallSite() + orderby f.Location.Distance(myLocation) descending + select f).Take(5).ToListAsync(); + #endregion + } } #region QueryableMethods From 7fc6794068423d96a13781b56a961d97f9bb1b02 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:45:57 +0000 Subject: [PATCH 3/6] Update line numbers in TagWithCallSite examples Co-authored-by: roji <1862641+roji@users.noreply.github.com> --- entity-framework/core/querying/tags.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entity-framework/core/querying/tags.md b/entity-framework/core/querying/tags.md index 5baf28da20..967d3dd68d 100644 --- a/entity-framework/core/querying/tags.md +++ b/entity-framework/core/querying/tags.md @@ -77,7 +77,7 @@ Starting with EF Core 6.0, queries can be automatically tagged with the file nam This query translates to: ```sql --- file: ...\samples\core\Querying\Tags\Program.cs:49 +-- file: ...\samples\core\Querying\Tags\Program.cs:48 SELECT TOP(@__p_1) [p].[Id], [p].[Location] FROM [People] AS [p] @@ -93,7 +93,7 @@ This produces: ```sql -- GetClosestPeople --- file: ...\samples\core\Querying\Tags\Program.cs:57 +-- file: ...\samples\core\Querying\Tags\Program.cs:58 SELECT TOP(@__p_1) [p].[Id], [p].[Location] FROM [People] AS [p] From 81bc870c35187388f40c017dca9648fcbac9a7bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:47:19 +0000 Subject: [PATCH 4/6] Add note about line numbers in TagWithCallSite documentation Co-authored-by: roji <1862641+roji@users.noreply.github.com> --- entity-framework/core/querying/tags.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entity-framework/core/querying/tags.md b/entity-framework/core/querying/tags.md index 967d3dd68d..c942736133 100644 --- a/entity-framework/core/querying/tags.md +++ b/entity-framework/core/querying/tags.md @@ -74,7 +74,7 @@ Starting with EF Core 6.0, queries can be automatically tagged with the file nam [!code-csharp[Main](../../../samples/core/Querying/Tags/Program.cs#TagWithCallSite)] -This query translates to: +This query translates to (the actual line number will reflect where the query is defined in the source file): ```sql -- file: ...\samples\core\Querying\Tags\Program.cs:48 From 39b34b386e0d05ad2e16699c5f77e55b8d4e8a8b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 10:40:56 +0000 Subject: [PATCH 5/6] Address review feedback: inline code sample, remove version reference, remove combination example Co-authored-by: roji <1862641+roji@users.noreply.github.com> --- entity-framework/core/querying/tags.md | 27 ++++++++------------------ samples/core/Querying/Tags/Program.cs | 20 ------------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/entity-framework/core/querying/tags.md b/entity-framework/core/querying/tags.md index c942736133..88ccecf971 100644 --- a/entity-framework/core/querying/tags.md +++ b/entity-framework/core/querying/tags.md @@ -70,30 +70,19 @@ ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC ## Tagging with file name and line number -Starting with EF Core 6.0, queries can be automatically tagged with the file name and line number where the LINQ query is defined in source code. This is done using the `TagWithCallSite()` method: +Queries can be automatically tagged with the file name and line number where the LINQ query is defined in source code. This is done using the `TagWithCallSite()` method: -[!code-csharp[Main](../../../samples/core/Querying/Tags/Program.cs#TagWithCallSite)] - -This query translates to (the actual line number will reflect where the query is defined in the source file): - -```sql --- file: ...\samples\core\Querying\Tags\Program.cs:48 - -SELECT TOP(@__p_1) [p].[Id], [p].[Location] -FROM [People] AS [p] -ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC +```csharp +var myLocation = new Point(1, 2); +var closestPeople = await (from f in context.People.TagWithCallSite() + orderby f.Location.Distance(myLocation) descending + select f).Take(5).ToListAsync(); ``` -The `TagWithCallSite()` method can be combined with `TagWith()` to provide both custom tags and call site information: - -[!code-csharp[Main](../../../samples/core/Querying/Tags/Program.cs#TagWithCallSiteAndTag)] - -This produces: +This query translates to (the actual line number will reflect where the query is defined in the source file): ```sql --- GetClosestPeople - --- file: ...\samples\core\Querying\Tags\Program.cs:58 +-- file: C:\Work\EntityFramework.Docs\samples\Program.cs:23 SELECT TOP(@__p_1) [p].[Id], [p].[Location] FROM [People] AS [p] diff --git a/samples/core/Querying/Tags/Program.cs b/samples/core/Querying/Tags/Program.cs index d19070c0b1..a376d7db13 100644 --- a/samples/core/Querying/Tags/Program.cs +++ b/samples/core/Querying/Tags/Program.cs @@ -40,26 +40,6 @@ orderby f.Location.Distance(myLocation) descending string").ToListAsync(); #endregion } - - using (var context = new SpatialContext()) - { - #region TagWithCallSite - var myLocation = new Point(1, 2); - var closestPeople = await (from f in context.People.TagWithCallSite() - orderby f.Location.Distance(myLocation) descending - select f).Take(5).ToListAsync(); - #endregion - } - - using (var context = new SpatialContext()) - { - #region TagWithCallSiteAndTag - var myLocation = new Point(1, 2); - var closestPeople = await (from f in context.People.TagWith("GetClosestPeople").TagWithCallSite() - orderby f.Location.Distance(myLocation) descending - select f).Take(5).ToListAsync(); - #endregion - } } #region QueryableMethods From a76404ab6db3a9641c3768ea32820d8cfb7a09ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 11:59:26 +0000 Subject: [PATCH 6/6] Use xref for TagWithCallSite API reference Co-authored-by: roji <1862641+roji@users.noreply.github.com> --- entity-framework/core/querying/tags.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entity-framework/core/querying/tags.md b/entity-framework/core/querying/tags.md index 88ccecf971..7b50b21a5b 100644 --- a/entity-framework/core/querying/tags.md +++ b/entity-framework/core/querying/tags.md @@ -70,7 +70,7 @@ ORDER BY [p].[Location].STDistance(@__myLocation_0) DESC ## Tagging with file name and line number -Queries can be automatically tagged with the file name and line number where the LINQ query is defined in source code. This is done using the `TagWithCallSite()` method: +Queries can be automatically tagged with the file name and line number where the LINQ query is defined in source code. This is done using the method: ```csharp var myLocation = new Point(1, 2);