From f8de2a33daa8a4f29a26083ae35f12264b13b3e9 Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:05:37 +0200 Subject: [PATCH 1/2] include a link to the data set within LINQ examples --- .../linq/includes/data-sources-definition.md | 14 ++++++++++++++ .../converting-data-types.md | 6 +----- .../linq/standard-query-operators/grouping-data.md | 6 +----- docs/csharp/linq/standard-query-operators/index.md | 2 ++ .../standard-query-operators/join-operations.md | 6 +----- .../standard-query-operators/set-operations.md | 6 +----- .../standard-query-operators/DataSources.cs | 1 + .../linq/standard-query-operators/sorting-data.md | 6 +----- 8 files changed, 22 insertions(+), 25 deletions(-) create mode 100644 docs/csharp/linq/includes/data-sources-definition.md diff --git a/docs/csharp/linq/includes/data-sources-definition.md b/docs/csharp/linq/includes/data-sources-definition.md new file mode 100644 index 0000000000000..8a289a8ba8121 --- /dev/null +++ b/docs/csharp/linq/includes/data-sources-definition.md @@ -0,0 +1,14 @@ +--- +author: BillWagner +ms.author: wiwagn +ms.topic: include +ms.date: 10/04/2024 +--- + +The following examples in this article use the common data sources for this area: + +:::code language="csharp" source="../standard-query-operators/snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: + +Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. + +You can find the data set in the [source repo](https://github.com/dotnet/docs/blob/main/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/DataSources.cs#L41). diff --git a/docs/csharp/linq/standard-query-operators/converting-data-types.md b/docs/csharp/linq/standard-query-operators/converting-data-types.md index eea9af0edff62..3f775f7590dc6 100644 --- a/docs/csharp/linq/standard-query-operators/converting-data-types.md +++ b/docs/csharp/linq/standard-query-operators/converting-data-types.md @@ -32,11 +32,7 @@ The conversion methods in this table whose names start with "As" change the stat |ToList|Converts a collection to a . This method forces query execution.|Not applicable.|| |ToLookup|Puts elements into a (a one-to-many dictionary) based on a key selector function. This method forces query execution.|Not applicable.|| -The following examples in this article use the common data sources for this area: - -:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: - -Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +[!INCLUDE [Datasources](../includes/data-sources-definition.md)] ## Query Expression Syntax Example diff --git a/docs/csharp/linq/standard-query-operators/grouping-data.md b/docs/csharp/linq/standard-query-operators/grouping-data.md index fc5bf1e607c96..8fe818384d311 100644 --- a/docs/csharp/linq/standard-query-operators/grouping-data.md +++ b/docs/csharp/linq/standard-query-operators/grouping-data.md @@ -26,11 +26,7 @@ The equivalent query using method syntax is shown in the following code: :::code language="csharp" source="./snippets/standard-query-operators/GroupOverview.cs" id="OverviewSampleMethodSyntax"::: -The following examples in this article use the common data sources for this area: - -:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: - -Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +[!INCLUDE [Datasources](../includes/data-sources-definition.md)] ## Group query results diff --git a/docs/csharp/linq/standard-query-operators/index.md b/docs/csharp/linq/standard-query-operators/index.md index d830483043dc0..3b9a11436e6ba 100644 --- a/docs/csharp/linq/standard-query-operators/index.md +++ b/docs/csharp/linq/standard-query-operators/index.md @@ -27,6 +27,8 @@ Where possible, the queries in this section use a sequence of words or numbers a Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +You can find the data set in the [source repo](https://github.com/dotnet/docs/blob/main/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/DataSources.cs#L41). + ## Types of query operators The standard query operators differ in the timing of their execution, depending on whether they return a singleton value or a sequence of values. Those methods that return a singleton value (such as and ) execute immediately. Methods that return a sequence defer the query execution and return an enumerable object. You can use the output sequence of one query as the input sequence to another query. Calls to query methods can be chained together in one query, which enables queries to become arbitrarily complex. diff --git a/docs/csharp/linq/standard-query-operators/join-operations.md b/docs/csharp/linq/standard-query-operators/join-operations.md index ca9a473936674..05c9c2db0aaea 100644 --- a/docs/csharp/linq/standard-query-operators/join-operations.md +++ b/docs/csharp/linq/standard-query-operators/join-operations.md @@ -25,11 +25,7 @@ The following illustration shows a conceptual view of two sets and the elements |Join|Joins two sequences based on key selector functions and extracts pairs of values.|`join … in … on … equals …`|

| |GroupJoin|Joins two sequences based on key selector functions and groups the resulting matches for each element.|`join … in … on … equals … into …`|

| -The following examples in this article use the common data sources for this area: - -:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: - -Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +[!INCLUDE [Datasources](../includes/data-sources-definition.md)] The following example uses the `join … in … on … equals …` clause to join two sequences based on specific value: diff --git a/docs/csharp/linq/standard-query-operators/set-operations.md b/docs/csharp/linq/standard-query-operators/set-operations.md index 095a01a015fa3..801c574ca575c 100644 --- a/docs/csharp/linq/standard-query-operators/set-operations.md +++ b/docs/csharp/linq/standard-query-operators/set-operations.md @@ -34,11 +34,7 @@ The following example depicts the behavior of

| |Reverse|Reverses the order of the elements in a collection.|Not applicable.|

| -The following examples in this article use the common data sources for this area: - -:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: - -Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +[!INCLUDE [Datasources](../includes/data-sources-definition.md)] ## Primary Ascending Sort From 0095e97f3d7450990f77e8f5dbf95d0c27c59eed Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Sun, 6 Oct 2024 18:41:32 +0200 Subject: [PATCH 2/2] convert text into note --- docs/csharp/linq/includes/data-sources-definition.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/csharp/linq/includes/data-sources-definition.md b/docs/csharp/linq/includes/data-sources-definition.md index 8a289a8ba8121..5112ce8960d25 100644 --- a/docs/csharp/linq/includes/data-sources-definition.md +++ b/docs/csharp/linq/includes/data-sources-definition.md @@ -5,10 +5,9 @@ ms.topic: include ms.date: 10/04/2024 --- -The following examples in this article use the common data sources for this area: +> [!NOTE] +> The following examples in this article use the common data sources for this area. +> Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. +> You can find the example data set in the [source repo](https://github.com/dotnet/docs/blob/main/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/DataSources.cs#L41). :::code language="csharp" source="../standard-query-operators/snippets/standard-query-operators/DataSources.cs" id="QueryDataSource"::: - -Each `Student` has a grade level, a primary department, and a series of scores. A `Teacher` also has a `City` property that identifies the campus where the teacher holds classes. A `Department` has a name, and a reference to a `Teacher` who serves as the department head. - -You can find the data set in the [source repo](https://github.com/dotnet/docs/blob/main/docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/DataSources.cs#L41).