次の方法で共有


QueryableExtensions.SumAsync<TSource> メソッド (IQueryable<TSource>, Expression<Func<TSource, Nullable<Single>>>)

[このページは、Entity Framework 6 に関するページです。最新バージョンは、'Entity Framework' NuGet パッケージとして入手できます。Entity Framework の詳細については、msdn.com/data/ef を参照してください。]

入力シーケンスの各要素に対して射影関数を呼び出して取得する null 許容の Single 値のシーケンスの合計を非同期に計算します。

名前空間:  System.Data.Entity
アセンブリ:  EntityFramework (EntityFramework.dll 内)

構文

'宣言
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
<ExtensionAttribute> _
Public Shared Function SumAsync(Of TSource) ( _
    source As IQueryable(Of TSource), _
    selector As Expression(Of Func(Of TSource, Nullable(Of Single))) _
) As Task(Of Nullable(Of Single))
'使用
Dim source As IQueryable(Of TSource)
Dim selector As Expression(Of Func(Of TSource, Nullable(Of Single)))
Dim returnValue As Task(Of Nullable(Of Single))

returnValue = source.SumAsync(selector)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public static Task<Nullable<float>> SumAsync<TSource>(
    this IQueryable<TSource> source,
    Expression<Func<TSource, Nullable<float>>> selector
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
[ExtensionAttribute]
public:
generic<typename TSource>
static Task<Nullable<float>>^ SumAsync(
    IQueryable<TSource>^ source, 
    Expression<Func<TSource, Nullable<float>>^>^ selector
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
static member SumAsync : 
        source:IQueryable<'TSource> * 
        selector:Expression<Func<'TSource, Nullable<float32>>> -> Task<Nullable<float32>> 
JScript does not support generic types and methods.

型パラメーター

  • TSource
    source の要素の型。

パラメーター

戻り値

型 : System.Threading.Tasks.Task<Nullable<Single>>
非同期操作を表すタスク。タスクの結果には、予測値の合計が示されます。

使用上の注意

Visual Basic および Visual C# では、このメソッドを、IQueryable<TSource> 型のオブジェクトのインスタンス メソッドとして呼び出すことができます。インスタンス メソッド構文を使用してこのメソッドを呼び出す場合は、最初のパラメーターを省略します。詳細については、「https://msdn.microsoft.com/ja-jp/library/bb384936(v=vs.113)」または「https://msdn.microsoft.com/ja-jp/library/bb383977(v=vs.113)」を参照してください。

例外

例外 状態
ArgumentNullException

source または selector が null です。

InvalidOperationException

source は IDbAsyncQueryProvider を実装しません。

解説

同じコンテキスト インスタンスに対する複数のアクティブ操作はサポートされません。 このコンテキストで別のメソッドを呼び出す前に、非同期操作が完了したことを確認するために await を使用します。

参照

参照

QueryableExtensions クラス

SumAsync オーバーロード

System.Data.Entity 名前空間