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.

decompiled , methods

there inversion in all method after predicate applied. relative 0 performance impact, code readability main concern.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -