C# Linq to Javascript Linq.js Help

Mar 14, 2012 at 9:04 PM
Edited Mar 14, 2012 at 9:17 PM

I have the following C# Linq,

Enumerable.Range(refx, rows)
    .SelectMany(
        x => Enumerable.Range(refy, columns),
        (x, y) => new {x, y})
    .Where(
        d =>
        (d.x >= 0 && d.y >= 0) &&
        (d.x <= rows && d.y <= columns))
    .Select(
        c => new Location(c.x, c.y));

I would like to have the same in Linq.js format could someone help solve this?

Thank you

Mar 27, 2012 at 6:57 PM

The solution :)

Enumerable.Range(refx, rows)
    .SelectMany(
        function(x) {
            return Enumerable.Range(refy, columns);
        },
        function (x, y) {
            return {x:x, y:y};
        })
    .Where(
        function(d) {
            return (d.x >= 0 && d.y >= 0) &&
                (d.x <= rows && d.y <= columns);
        })
    .Select(
        function(c) {
            return new LocationXY(c.x, c.y);
        }).ToArray();