ENikS/LINQ

Concat() element duplicate.

Closed this issue · 2 comments

import { asEnumerable as linq } from 'linq-es5';

const xs = [{ x: 'x', b: true }, { x: 'y', b: false }, { x: 'z', b: true }];
const lq = linq(xs).Where(f => f.b).Concat(linq(xs).Where(f => !f.b));
console.log(lq.ToArray());

/*
    {x: "x", b: true}
    {x: "y", b: false}
    {x: "z", b: true}
    {x: "y", b: false}
*/

The same code in C#

var xs = new[] { new { x = 'x', b = true }, new { x = 'y', b = false }, new { x = 'z', b = true } };
var lq = xs.Where(f => f.b).Concat(xs.Where(f => !f.b));
foreach (var item in lq)
{
    Console.WriteLine($"{item.x} {item.b}");
}
/*
    x True
    z True
    y False
*/

BUT below is ok in ts

const xs = [{ x: 'x', b: true }, { x: 'y', b: false }, { x: 'z', b: true }];
console.log(linq(xs).Where(f => f.b).ToArray());
/*
    {x: "x", b: true}
    {x: "z", b: true}
*/
console.log(linq(xs).Where(f => !f.b).ToArray())
/*
    {x: "y", b: false}
*/
ENikS commented

Thank you for feedback, will take a look

This issue still exists. At least in the package on NPM for linq-es5. Was this fix applied there?