Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Queryable::Any<TSource> Method (IQueryable<TSource>^)

 

Determines whether a sequence contains any elements.

Namespace:   System.Linq
Assembly:  System.Core (in System.Core.dll)

public:
generic<typename TSource>
[ExtensionAttribute]
static bool Any(
	IQueryable<TSource>^ source
)

Parameters

source
Type: System.Linq::IQueryable<TSource>^

A sequence to check for being empty.

Return Value

Type: System::Boolean

true if the source sequence contains any elements; otherwise, false.

Type Parameters

TSource

The type of the elements of source.

Exception Condition
ArgumentNullException

source is null.

The Any<TSource>(IQueryable<TSource>^) method generates a MethodCallExpression that represents calling Any<TSource>(IQueryable<TSource>^) itself as a constructed generic method. It then passes the MethodCallExpression to the Execute<TResult>(Expression^) method of the IQueryProvider represented by the Provider property of the source parameter.

The query behavior that occurs as a result of executing an expression tree that represents calling Any<TSource>(IQueryable<TSource>^) depends on the implementation of the type of the source parameter. The expected behavior is that it determines if source contains any elements.

The following code example demonstrates how to use Any<TSource>(IQueryable<TSource>^) to determine whether a sequence contains any elements.

No code example is currently available or this language may not be supported.

The Boolean value that the Any<TSource>(IQueryable<TSource>^) method returns is typically used in the predicate of a where clause (Where clause in Visual Basic) or a direct call to the Where<TSource>(IQueryable<TSource>^, Expression<Func<TSource, Boolean>^>^) method. The following example demonstrates this use of the Any method.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft