HpcLinqQueryable.ContainsAsQuery Method (IQueryable, TSource)

Creates a query that you can run later to determine whether a set of records contains the specified record by using the default equality comparer to compare records.

Namespace: Microsoft.Hpc.Linq
Assembly: Microsoft.Hpc.Linq (in Microsoft.Hpc.Linq.dll)


Dim source As IQueryable(Of TSource)
Dim item As TSource
Dim returnValue As IQueryable(Of Boolean)

returnValue = HpcLinqQueryable.ContainsAsQuery(source, item)


<ExtensionAttribute> _
Public Shared Function ContainsAsQuery(Of TSource) ( _
    source As IQueryable(Of TSource), _
    item As TSource _
) As IQueryable(Of Boolean)
public static IQueryable<bool> ContainsAsQuery<TSource> (
    IQueryable<TSource> source,
    TSource item
generic<typename TSource>
static IQueryable<bool>^ ContainsAsQuery (
    IQueryable<TSource>^ source, 
    TSource item
J# supports the use of generic APIs, but not the declaration of new ones.
JScript does not support generic types or methods.


  • TSource
    The type of the records in the source parameter.


  • item
    An object of the type that the TSource parameter specifies that is the record that you want to match in the set of records.

Return Value

An IQueryable interface for the query.


Exception type Condition

The specified source parameter is a null reference (Nothing in Visual Basic).


Use this method if you want to perform the same query as the Contains method, but want to delay running the query instead of generating results immediately.

Use the Submit method to run the query. Use the GetEnumerator method or the foreach statement of the C# language (For Each in Visual Basic) to get the results of the query. The enumerator contains a single Boolean element, which has a value of true if set of records contains the specified record, or false if the set of records does not contain the specified record.

To create a query that tests whether the set of records contains a record by using an IEqualityComparer interface that you specify to compare the records, use the ContainsAsQuery(Generic IQueryable,J,Generic IEqualityComparer) form of the method.

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable<TSource>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

For more information about how the query runs and its behavior, see the Remarks section for the Contains method.

Platform Note: This method was introduced in Windows HPC Server 2008 R2 with Service Pack 2 (SP2) and is not supported in previous versions.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Development Platforms

Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

Target Platforms

Windows XP, Windows Vista, Windows 7, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, with HPC Pack Client Utilities

See Also


HpcLinqQueryable Class
HpcLinqQueryable Members
Microsoft.Hpc.Linq Namespace
ContainsAsQuery(Generic IQueryable,J,Generic IEqualityComparer)

Build Date: