Skip to content

Commit 108265f

Browse files
committed
include a link to the data set within LINQ examples
1 parent a512438 commit 108265f

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
author: BillWagner
3+
ms.author: wiwagn
4+
ms.topic: include
5+
ms.date: 10/04/2024
6+
---
7+
8+
The following examples in this article use the common data sources for this area:
9+
10+
:::code language="csharp" source="../standard-query-operators/snippets/standard-query-operators/DataSources.cs" id="QueryDataSourceModels":::
11+
12+
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.
13+
14+
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).

docs/csharp/linq/standard-query-operators/converting-data-types.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ The conversion methods in this table whose names start with "As" change the stat
3232
|ToList|Converts a collection to a <xref:System.Collections.Generic.List%601>. This method forces query execution.|Not applicable.|<xref:System.Linq.Enumerable.ToList%2A?displayProperty=nameWithType>|
3333
|ToLookup|Puts elements into a <xref:System.Linq.Lookup%602> (a one-to-many dictionary) based on a key selector function. This method forces query execution.|Not applicable.|<xref:System.Linq.Enumerable.ToLookup%2A?displayProperty=nameWithType>|
3434

35-
The following examples in this article use the common data sources for this area:
36-
37-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
38-
39-
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.
35+
[!INCLUDE [Datasources](../includes/data-sources-definition.md)]
4036

4137
## Query Expression Syntax Example
4238

docs/csharp/linq/standard-query-operators/grouping-data.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ The equivalent query using method syntax is shown in the following code:
2626

2727
:::code language="csharp" source="./snippets/standard-query-operators/GroupOverview.cs" id="OverviewSampleMethodSyntax":::
2828

29-
The following examples in this article use the common data sources for this area:
30-
31-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
32-
33-
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.
29+
[!INCLUDE [Datasources](../includes/data-sources-definition.md)]
3430

3531
## Group query results
3632

docs/csharp/linq/standard-query-operators/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ The following code example demonstrates how the standard query operators can be
2323

2424
Where possible, the queries in this section use a sequence of words or numbers as the input source. For queries where more complicated relationships between objects are used, the following sources that model a school are used:
2525

26-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
26+
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSourceModels":::
2727

2828
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.
2929

30+
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).
31+
3032
## Types of query operators
3133

3234
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 <xref:System.Linq.Enumerable.Average%2A> and <xref:System.Linq.Enumerable.Sum%2A>) 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.

docs/csharp/linq/standard-query-operators/join-operations.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ The following illustration shows a conceptual view of two sets and the elements
2525
|Join|Joins two sequences based on key selector functions and extracts pairs of values.|`join … in … on … equals …`|<xref:System.Linq.Enumerable.Join%2A?displayProperty=nameWithType><br /><br /> <xref:System.Linq.Queryable.Join%2A?displayProperty=nameWithType>|
2626
|GroupJoin|Joins two sequences based on key selector functions and groups the resulting matches for each element.|`join … in … on … equals … into …`|<xref:System.Linq.Enumerable.GroupJoin%2A?displayProperty=nameWithType><br /><br /> <xref:System.Linq.Queryable.GroupJoin%2A?displayProperty=nameWithType>|
2727

28-
The following examples in this article use the common data sources for this area:
29-
30-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
31-
32-
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.
28+
[!INCLUDE [Datasources](../includes/data-sources-definition.md)]
3329

3430
The following example uses the `join … in … on … equals …` clause to join two sequences based on specific value:
3531

docs/csharp/linq/standard-query-operators/set-operations.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ The following example depicts the behavior of <xref:System.Linq.Enumerable.Excep
3434

3535
:::image type="content" source="./media/set-operations/except-behavior-graphic.png" alt-text="Graphic showing the action of Except()":::
3636

37-
The following examples in this article use the common data sources for this area:
38-
39-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
40-
41-
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.
37+
[!INCLUDE [Datasources](../includes/data-sources-definition.md)]
4238

4339
:::code language="csharp" source="./snippets/standard-query-operators/SetOperations.cs" id="Except":::
4440

docs/csharp/linq/standard-query-operators/snippets/standard-query-operators/DataSources.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace StandardQueryOperators;
22

3-
//<QueryDataSource>
3+
//<QueryDataSourceModels>
44
public enum GradeLevel
55
{
66
FirstYear = 1,
@@ -28,15 +28,17 @@ public class Teacher
2828
public required int ID { get; init; }
2929
public required string City { get; init; }
3030
}
31+
3132
public class Department
3233
{
3334
public required string Name { get; init; }
3435
public int ID { get; init; }
3536

3637
public required int TeacherID { get; init; }
3738
}
38-
// </QueryDataSource>
39+
// </QueryDataSourceModels>
3940

41+
//<QueryDataSource>
4042
public static class Sources
4143
{
4244
public static IEnumerable<Department> Departments =>
@@ -132,3 +134,4 @@ public static class Sources
132134
new() { First = "Noel", Last = "Svensson", ID = 973, City = "Seattle" }
133135
];
134136
}
137+
// </QueryDataSource>

docs/csharp/linq/standard-query-operators/sorting-data.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ The standard query operator methods that sort data are listed in the following s
2525
|ThenByDescending|Performs a secondary sort in descending order.|`orderby …, … descending`|<xref:System.Linq.Enumerable.ThenByDescending%2A?displayProperty=nameWithType><br /><br /> <xref:System.Linq.Queryable.ThenByDescending%2A?displayProperty=nameWithType>|
2626
|Reverse|Reverses the order of the elements in a collection.|Not applicable.|<xref:System.Linq.Enumerable.Reverse%2A?displayProperty=nameWithType><br /><br /> <xref:System.Linq.Queryable.Reverse%2A?displayProperty=nameWithType>|
2727

28-
The following examples in this article use the common data sources for this area:
29-
30-
:::code language="csharp" source="./snippets/standard-query-operators/DataSources.cs" id="QueryDataSource":::
31-
32-
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.
28+
[!INCLUDE [Datasources](../includes/data-sources-definition.md)]
3329

3430
## Primary Ascending Sort
3531

0 commit comments

Comments
 (0)