【BUG】FirstOrDefault Always First Data,ignore Where condition
xingwen1987 opened this issue · comments
Richfiter commented
RT,@3.0.4,FirstOrDefault Method Always Return First Data,ignore Where condition。
Richfiter commented
这个问题从 codeplex 版本就一直存在,到目前为止,依然没有解决,Orz。。。
AlexLEWIS commented
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' ");
AlexLEWIS commented
@mihaifm, I think the signature function(predicate, defaultValue)
is better than function(defaultValue,predicate)
, for it is much closer to C# LINQ.
Mihai Ciuraru commented
Which version are you looking at? It's like this in the code:
Enumerable.prototype.firstOrDefault = function (predicate, defaultValue) {
AlexLEWIS commented
copy that... I just upgraded to the latest version, thx a lot ( • ̀ω•́ )✧
Mihai Ciuraru commented
cool, no problem