How about this expression?
Email.AsEnumerable.Where() (Function(s) s.Subject.Tostring.Contains("RE")).Tostring.Any
Regards
gokul
Email.Any(Function(s) s.Subject.Tostring.Contains("RE"))
it is not recommended to use an empty Any() at the end
we assume that Email is a collection with Emails of Type MailMessages or other object having a subject property
We suggest to use a more descriptive Variable name expressing that it is a collection / multiple items
There is no difference between Collection.Any(condition) and Collection.Where(condition).Any
Using Any at the end of the expression is absolutely fine.
Please take a look at the Official Microsoft VB.net documentation:
Enumerable.Any Method (System.Linq) | Microsoft Learn
this is incorrect and can be show cased on possible side effects
Do you mean the Microsoft documentation is incorrect?
Can you share any example of these side effects?
we keep this thread clean. Feel free to open a separate topic if you see the need for this
No, but some details / specifics comes with more strict differentation
currently there is also linked a docu page not more set to Framework 4.6.1 and programming languages -
as it is mentioned as a possible side effect we can reduce the risk when strictly formulating the lambda for the any operator.
Here’s a link to the Framework 4.6.1 Official Microsoft Documentation that says pretty much the same thing:
Enumerable.Any Method (System.Linq) | Microsoft Learn
Again, The Boolean value that the Any method returns is typically used in the predicate of a where clause method.
If you don’t have practical cases to share, then, i don’t think this is very constructive.
I don’t need the open any new topic. Feel free to open a separate topic/tutorial once you have concrete examples that demonstrate your statements.
Email.Where(Function(s) s.Subject.Tostring.Contains(“RE”)).Count>0
Output : Boolean
Email.Any(Function(s) s.Subject.Tostring.Contains(“RE”))
Output : Boolean