-
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
groupJoin
produces empty result when inner is empty. Let's see the following example.
const Enumerable = require("node-enumerable");
const persons = [
{ name: "Tanja" },
{ name: "Marcel" },
{ name: "Yvonne" },
{ name: "Josefine" }
];
const pets = [];
const e = Enumerable.from(persons)
.groupJoin(
pets,
person => person.name,
pet => pet.owner.name,
(person, pets) => { person, pets }
)
.toArray();
Online runner
The example will result in an empty array []
.
Expected result would be:
[
{ person: { name: "Tanja" }, pets: [] },
{ person: { name: "Marcel" }, pets: [] },
{ person: { name: "Yvonne" }, pets: [] },
{ person: { name: "Josefine" }, pets: [] }
]
Corresponding C# code produces the expected result.
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var people = new Person[]
{
new Person("Tanja"),
new Person("Marcel"),
new Person("Yvonne"),
new Person("Josefine")
};
var pets = new Pet[0];
var e = people.GroupJoin(
pets,
person => person.Name,
pet => pet.Owner.Name,
(person, ps) => new { Person = person, Pets = ps }
).ToArray();
}
}
public class Person
{
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
}
public class Pet
{
public string Name { get; set; }
public Person Owner { get; set; }
public Pet(string name, Person owner)
{
Name = name;
Owner = owner;
}
}
Metadata
Metadata
Assignees
Labels
No labels