c# - LINQ and ReSharper -
hi have following code:
if (!_jobs.any(j => j.id == emailjob.id)) { }
this code should find elements satisfy condition. assume should return after finding first element, this:
if (!_jobs.firstordefault(j => j.id == emailjob.id) != null) { }
resharper tries simplify linq expression to:
if (_jobs.all(j => j.id != emailjob.id)) { }
this seems less efficient me because has check every single element satisifies inverse condition.
sorry if i'm misunderstanding how linq works.
joe
both any
, all
stop looking upon condition failing.
if looking more taking our word or anecdotal evidence, can see source doing.
there inversion in all
method after predicate applied. relative 0 performance impact, code readability main concern.
Comments
Post a Comment