Lexious
Lexious

Reputation: 13

My LINQ count query returns the wrong result

I'm using linq.js to use LINQ in my JavaScript code. When trying to filter out an array, I'm getting a bogus output. What am I doing wrong?

Code:

console.log($.Enumerable.From(streams.Medias["User Feeds"][a].Streams).Where('x => x.Name.length > 0').Count);

Output (in the browser console):

function (a){a=a==b?g.True:d.CreateLambda(a);var c=0;this.ForEach(function(d,b){if(a(d,b))++c});return c} 

Upvotes: 0

Views: 2017

Answers (2)

Jeff Mercado
Jeff Mercado

Reputation: 134841

Count is a function. You must call it to get the value.

var count = $.Enumerable.From(streams.Medias["User Feeds"][a].Streams)
    .Where('x => x.Name.length > 0')
    .Count();

Upvotes: 1

Lexious
Lexious

Reputation: 13

Forget it, solved it using jquery $.grep which does the same thing.

Upvotes: 0

Related Questions