mihaifm / linq

linq.js - LINQ for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

【BUG】FirstOrDefault Always First Data,ignore Where condition

xingwen1987 opened this issue · comments

RT,@3.0.4,FirstOrDefault Method Always Return First Data,ignore Where condition。

这个问题从 codeplex 版本就一直存在,到目前为止,依然没有解决,Orz。。。

the signatures for the FirstOrDefault function is

// Overload:function(defaultValue)
// Overload:function(defaultValue,predicate)

so, @xingwen1987 , you should written as:

var result = Enumerable.From(someCollection).firstOrDefault(null, "foo => foo == 'bar' ");

@mihaifm, I think the signature function(predicate, defaultValue) is better than function(defaultValue,predicate), for it is much closer to C# LINQ.

Which version are you looking at? It's like this in the code:

Enumerable.prototype.firstOrDefault = function (predicate, defaultValue) {

https://github.com/mihaifm/linq/blob/master/linq.js#L1861

copy that... I just upgraded to the latest version, thx a lot ( • ̀ω•́ )✧

cool, no problem

@mihaifm OK,I'll update my project。