HpcLinqQueryable.SingleAsQuery Method (IQueryable, Expression)
Creates a query that you can run later to get the only record in a set of records that satisfies the condition for which the specified function tests.
Assembly: Microsoft.Hpc.Linq (in Microsoft.Hpc.Linq.dll)
'Usage Dim source As IQueryable(Of TSource) Dim predicate As Expression(Of Func(Of TSource, Boolean)) Dim returnValue As IQueryable(Of TSource) returnValue = HpcLinqQueryable.SingleAsQuery(source, predicate)
'Declaration <ExtensionAttribute> _ Public Shared Function SingleAsQuery(Of TSource) ( _ source As IQueryable(Of TSource), _ predicate As Expression(Of Func(Of TSource, Boolean)) _ ) As IQueryable(Of TSource)
[ExtensionAttribute] public static IQueryable<TSource> SingleAsQuery<TSource> ( IQueryable<TSource> source, Expression<Func<TSource,bool>> predicate )
[ExtensionAttribute] public: generic<typename TSource> static IQueryable<TSource>^ SingleAsQuery ( IQueryable<TSource>^ source, Expression<Func<TSource, bool>^>^ predicate )
J# supports the use of generic APIs, but not the declaration of new ones.
JScript does not support generic types or methods.
The type of the records in the source parameter.
A System.Linq.IQueryable<TSource> interface for the set of records for which you want to get the only record in the set that satisfies the conditions for which the function tests.
A System.Linq.Expressions.Expression(Func(TSource, Boolean)) object that specifies a function that tests whether each record satisfies a condition.
An IQueryable interface for the query.
The specified source or predicate parameter is a null reference (Nothing in Visual Basic).
Use this method if you want to perform the same query as the Single 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 item of the type that the TSource parameter specifies and that is the only record in the set of records that satisfies the conditions for which the specified function tests. If the set of records contains does not contain exactly one record that satisfies those conditions, the job that runs the query on the HPC cluster fails because an HpcLinqException occurs, and an HpcLinqException also occurs if you try to use the GetEnumerator method or the foreach statement of the C# language (For Each in Visual Basic) to get the results of the query.
To create a query that you can run later to get the only record in a set of records without testing if the record satisfies any conditions, use the SingleAsQuery(Generic IQueryable) 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).
This method has at least one parameter of type Expression with a type argument that is one of the Func types. For these parameters, you can pass in a lambda expression and it compiles to an Expression.
For more information about how the query runs and its behavior, see the Remarks section for the Single 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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows XP, Windows Vista, Windows 7, Windows 8, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012
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