Skip to content

Commit

Permalink
Add linqpad samples for new XxxJoin methods (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceroypenguin authored Feb 16, 2024
1 parent acc01e1 commit d8fd221
Show file tree
Hide file tree
Showing 24 changed files with 1,083 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
uid: SuperLinq.SuperEnumerable.FullOuterHashJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an full outer hash join of two sequences using `FullOuterHashJoin`.
[!code-csharp[](SuperLinq/FullOuterHashJoin/FullOuterHashJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.FullOuterHashJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``3},System.Func{``1,``3},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an full outer hash join of two sequences using `FullOuterHashJoin`.
[!code-csharp[](SuperLinq/FullOuterHashJoin/FullOuterHashJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.FullOuterMergeJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an full outer merge join of two sequences using `FullOuterMergeJoin`.
[!code-csharp[](SuperLinq/FullOuterMergeJoin/FullOuterMergeJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.FullOuterMergeJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``3},System.Func{``1,``3},System.Func{``0,``1,``3},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an full outer merge join of two sequences using `FullOuterMergeJoin`.
[!code-csharp[](SuperLinq/FullOuterMergeJoin/FullOuterMergeJoin2.linq#L6-)]
41 changes: 41 additions & 0 deletions Docs/SuperLinq.Docs/apidoc/SuperLinq.SuperEnumerable.InnerJoin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
uid: SuperLinq.SuperEnumerable.InnerHashJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner hash join of two sequences using `InnerHashJoin`.
[!code-csharp[](SuperLinq/InnerHashJoin/InnerHashJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.InnerHashJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner hash join of two sequences using `InnerHashJoin`.
[!code-csharp[](SuperLinq/InnerHashJoin/InnerHashJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.InnerLoopJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner loop join of two sequences using `InnerLoopJoin`.
[!code-csharp[](SuperLinq/InnerLoopJoin/InnerLoopJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.InnerLoopJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner loop join of two sequences using `InnerLoopJoin`.
[!code-csharp[](SuperLinq/InnerLoopJoin/InnerLoopJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.InnerMergeJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner merge join of two sequences using `InnerMergeJoin`.
[!code-csharp[](SuperLinq/InnerMergeJoin/InnerMergeJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.InnerMergeJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``1,``3},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an inner merge join of two sequences using `InnerMergeJoin`.
[!code-csharp[](SuperLinq/InnerMergeJoin/InnerMergeJoin2.linq#L6-)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
uid: SuperLinq.SuperEnumerable.LeftOuterHashJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer hash join of two sequences using `LeftOuterHashJoin`.
[!code-csharp[](SuperLinq/LeftOuterHashJoin/LeftOuterHashJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.LeftOuterHashJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``3},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer hash join of two sequences using `LeftOuterHashJoin`.
[!code-csharp[](SuperLinq/LeftOuterHashJoin/LeftOuterHashJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.LeftOuterLoopJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer loop join of two sequences using `LeftOuterLoopJoin`.
[!code-csharp[](SuperLinq/LeftOuterLoopJoin/LeftOuterLoopJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.LeftOuterLoopJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``3},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer loop join of two sequences using `LeftOuterLoopJoin`.
[!code-csharp[](SuperLinq/LeftOuterLoopJoin/LeftOuterLoopJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.LeftOuterMergeJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer merge join of two sequences using `LeftOuterMergeJoin`.
[!code-csharp[](SuperLinq/LeftOuterMergeJoin/LeftOuterMergeJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.LeftOuterMergeJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``0,``3},System.Func{``0,``1,``3},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an left outer merge join of two sequences using `LeftOuterMergeJoin`.
[!code-csharp[](SuperLinq/LeftOuterMergeJoin/LeftOuterMergeJoin2.linq#L6-)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
uid: SuperLinq.SuperEnumerable.RightOuterHashJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an right outer hash join of two sequences using `RightOuterHashJoin`.
[!code-csharp[](SuperLinq/RightOuterHashJoin/RightOuterHashJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.RightOuterHashJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``1,``3},System.Func{``0,``1,``3},System.Collections.Generic.IEqualityComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an right outer hash join of two sequences using `RightOuterHashJoin`.
[!code-csharp[](SuperLinq/RightOuterHashJoin/RightOuterHashJoin2.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.RightOuterMergeJoin``3(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an right outer merge join of two sequences using `RightOuterMergeJoin`.
[!code-csharp[](SuperLinq/RightOuterMergeJoin/RightOuterMergeJoin1.linq#L6-)]

---
uid: SuperLinq.SuperEnumerable.RightOuterMergeJoin``4(System.Collections.Generic.IEnumerable{``0},System.Collections.Generic.IEnumerable{``1},System.Func{``0,``2},System.Func{``1,``2},System.Func{``1,``3},System.Func{``0,``1,``3},System.Collections.Generic.IComparer{``2})
example: [*content]
---
The following code example demonstrates how to execute an right outer merge join of two sequences using `RightOuterMergeJoin`.
[!code-csharp[](SuperLinq/RightOuterMergeJoin/RightOuterMergeJoin2.linq#L6-)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Query Kind="Statements">
<NuGetReference>SuperLinq</NuGetReference>
<Namespace>SuperLinq</Namespace>
</Query>

var people = new Person[]
{
new("John Doe", 1),
new("Jane Doe", 6),
new("Lucy Ricardo", 4),
new("Ricky Ricardo", 2),
new("Fred Mertz", 3),
new("Ethel Mertz", 5),
};

var pets = new Pet[]
{
new("Bear", 8),
new("Polly", 2),
new("Minnie", 2),
new("Mittens", 1),
new("Patches", 1),
new("Paws", 1),
};

var results = people
.FullOuterHashJoin(
pets,
p => p.PersonId,
p => p.PersonId);

foreach (var (person, pet) in results)
{
Console.WriteLine($"({person?.Name ?? "N/A"}, {pet?.Name ?? "No Pets"})");
}

// This code produces the following output:
// (John Doe, Mittens)
// (John Doe, Patches)
// (John Doe, Paws)
// (Jane Doe, No Pets)
// (Lucy Ricardo, No Pets)
// (Ricky Ricardo, Polly)
// (Ricky Ricardo, Minnie)
// (Fred Mertz, No Pets)
// (Ethel Mertz, No Pets)
// (N/A, Bear)

record Person(string Name, int PersonId);
record Pet(string Name, int PersonId);
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Query Kind="Statements">
<NuGetReference>SuperLinq</NuGetReference>
<Namespace>SuperLinq</Namespace>
</Query>

var people = new Person[]
{
new("John Doe", 1),
new("Jane Doe", 6),
new("Lucy Ricardo", 4),
new("Ricky Ricardo", 2),
new("Fred Mertz", 3),
new("Ethel Mertz", 5),
};

var pets = new Pet[]
{
new("Bear", 8),
new("Polly", 2),
new("Minnie", 2),
new("Mittens", 1),
new("Patches", 1),
new("Paws", 1),
};

var results = people
.FullOuterHashJoin(
pets,
p => p.PersonId,
p => p.PersonId,
person => $"({person.Name}, No Pets)",
pet => $"(N/A, {pet.Name})",
(person, pet) => $"({person.Name}, {pet.Name})");

foreach (var str in results)
Console.WriteLine(str);

// This code produces the following output:
// (John Doe, Mittens)
// (John Doe, Patches)
// (John Doe, Paws)
// (Jane Doe, No Pets)
// (Lucy Ricardo, No Pets)
// (Ricky Ricardo, Polly)
// (Ricky Ricardo, Minnie)
// (Fred Mertz, No Pets)
// (Ethel Mertz, No Pets)
// (N/A, Bear)

record Person(string Name, int PersonId);
record Pet(string Name, int PersonId);
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Query Kind="Statements">
<NuGetReference>SuperLinq</NuGetReference>
<Namespace>SuperLinq</Namespace>
</Query>

var people = new Person[]
{
new("John Doe", 1),
new("Jane Doe", 6),
new("Lucy Ricardo", 4),
new("Ricky Ricardo", 2),
new("Fred Mertz", 3),
new("Ethel Mertz", 5),
};

var pets = new Pet[]
{
new("Bear", 8),
new("Polly", 2),
new("Minnie", 2),
new("Mittens", 1),
new("Patches", 1),
new("Paws", 1),
};

var results = people.OrderBy(p => p.PersonId)
.FullOuterMergeJoin(
pets.OrderBy(p => p.PersonId),
p => p.PersonId,
p => p.PersonId);

foreach (var (person, pet) in results)
{
Console.WriteLine($"({person?.Name ?? "N/A"}, {pet?.Name ?? "No Pets"})");
}

// This code produces the following output:
// (John Doe, Mittens)
// (John Doe, Patches)
// (John Doe, Paws)
// (Jane Doe, No Pets)
// (Lucy Ricardo, No Pets)
// (Ricky Ricardo, Polly)
// (Ricky Ricardo, Minnie)
// (Fred Mertz, No Pets)
// (Ethel Mertz, No Pets)
// (N/A, Bear)

record Person(string Name, int PersonId);
record Pet(string Name, int PersonId);
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<Query Kind="Statements">
<NuGetReference>SuperLinq</NuGetReference>
<Namespace>SuperLinq</Namespace>
</Query>

var people = new Person[]
{
new("John Doe", 1),
new("Jane Doe", 6),
new("Lucy Ricardo", 4),
new("Ricky Ricardo", 2),
new("Fred Mertz", 3),
new("Ethel Mertz", 5),
};

var pets = new Pet[]
{
new("Bear", 8),
new("Polly", 2),
new("Minnie", 2),
new("Mittens", 1),
new("Patches", 1),
new("Paws", 1),
};

var results = people.OrderBy(p => p.PersonId)
.FullOuterMergeJoin(
pets.OrderBy(p => p.PersonId),
p => p.PersonId,
p => p.PersonId,
person => $"({person.Name}, No Pets)",
pet => $"(N/A, {pet.Name})",
(person, pet) => $"({person.Name}, {pet.Name})");

foreach (var str in results)
Console.WriteLine(str);

// This code produces the following output:
// (John Doe, Mittens)
// (John Doe, Patches)
// (John Doe, Paws)
// (Jane Doe, No Pets)
// (Lucy Ricardo, No Pets)
// (Ricky Ricardo, Polly)
// (Ricky Ricardo, Minnie)
// (Fred Mertz, No Pets)
// (Ethel Mertz, No Pets)
// (N/A, Bear)

record Person(string Name, int PersonId);
record Pet(string Name, int PersonId);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Query Kind="Statements">
<NuGetReference>SuperLinq</NuGetReference>
<Namespace>SuperLinq</Namespace>
</Query>

var people = new Person[]
{
new("John Doe", 1),
new("Jane Doe", 6),
new("Lucy Ricardo", 4),
new("Ricky Ricardo", 2),
new("Fred Mertz", 3),
new("Ethel Mertz", 5),
};

var pets = new Pet[]
{
new("Bear", 8),
new("Polly", 2),
new("Minnie", 2),
new("Mittens", 1),
new("Patches", 1),
new("Paws", 1),
};

var results = people
.InnerHashJoin(
pets,
p => p.PersonId,
p => p.PersonId);

foreach (var (person, pet) in results)
{
Console.WriteLine($"({person.Name}, {pet.Name})");
}

// This code produces the following output:
// (John Doe, Mittens)
// (John Doe, Patches)
// (John Doe, Paws)
// (Ricky Ricardo, Polly)
// (Ricky Ricardo, Minnie)

record Person(string Name, int PersonId);
record Pet(string Name, int PersonId);
Loading

0 comments on commit d8fd221

Please sign in to comment.