Queryable.Min Queryable.Min Queryable.Min Queryable.Min Method

定義

オーバーロード

Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)

ジェネリックの各要素に対して射影関数を呼び出しIQueryable<T>し、結果の最小値を返します。Invokes a projection function on each element of a generic IQueryable<T> and returns the minimum resulting value.

Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>)

ジェネリック型の最小値を返しますIQueryable<T>します。Returns the minimum value of a generic IQueryable<T>.

Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)

ジェネリックの各要素に対して射影関数を呼び出しIQueryable<T>し、結果の最小値を返します。Invokes a projection function on each element of a generic IQueryable<T> and returns the minimum resulting value.

public:
generic <typename TSource, typename TResult>
[System::Runtime::CompilerServices::Extension]
 static TResult Min(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TResult> ^> ^ selector);
public static TResult Min<TSource,TResult> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TResult>> selector);
static member Min : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Result>> -> 'Result
<Extension()>
Public Function Min(Of TSource, TResult) (source As IQueryable(Of TSource), selector As Expression(Of Func(Of TSource, TResult))) As TResult

型パラメーター

TSource

source の要素の型。The type of the elements of source.

TResult

表された関数によって返される値の型selectorします。The type of the value returned by the function represented by selector.

パラメーター

source
IQueryable<TSource>

最小値を決定する値のシーケンス。A sequence of values to determine the minimum of.

selector
Expression<Func<TSource,TResult>>

各要素に適用する射影関数。A projection function to apply to each element.

戻り値

TResult TResult TResult TResult

シーケンスの最小値。The minimum value in the sequence.

例外

source または selectornull です。source or selector is null.

次のコード例は、使用する方法を示しますMin<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)射影された値のシーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) to determine the minimum value in a sequence of projected values.

class Pet
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public static void MinEx2()
{
    Pet[] pets = { new Pet { Name="Barley", Age=8 },
                   new Pet { Name="Boots", Age=4 },
                   new Pet { Name="Whiskers", Age=1 } };

    // Get the Pet object that has the smallest Age value.
    int min = pets.AsQueryable().Min(pet => pet.Age);

    Console.WriteLine("The youngest animal is age {0}.", min);
}

/*
    This code produces the following output:

    The youngest animal is age 1.  
*/

Structure Pet
    Public Name As String
    Public Age As Integer
End Structure

Shared Sub MinEx2()
    Dim pets() As Pet = {New Pet With {.Name = "Barley", .Age = 8}, _
                   New Pet With {.Name = "Boots", .Age = 4}, _
                   New Pet With {.Name = "Whiskers", .Age = 1}}

    ' Get the Pet object that has the smallest Age value.
    Dim min As Integer = pets.AsQueryable().Min(Function(pet) pet.Age)

    MsgBox(String.Format("The youngest animal is age {0}.", min))
End Sub

'This code produces the following output:

'The youngest animal is age 1.  

注釈

このメソッドは、少なくとも 1 つのパラメーター型のExpression<TDelegate>型引数は、のいずれか、Func<T,TResult>型。This method has at least one parameter of type Expression<TDelegate> whose type argument is one of the Func<T,TResult> types. ラムダ式で、これらのパラメーターを渡すことができますにコンパイルされると、Expression<TDelegate>します。For these parameters, you can pass in a lambda expression and it will be compiled to an Expression<TDelegate>.

Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)メソッドを生成、MethodCallExpression呼び出しを表すMin<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)として構築されたジェネリック メソッド自体。The Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) method generates a MethodCallExpression that represents calling Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) itself as a constructed generic method. これは、後、渡します、MethodCallExpressionExecute<TResult>(Expression)のメソッド、IQueryProviderによって表される、Providerのプロパティ、sourceパラメーター。It then passes the MethodCallExpression to the Execute<TResult>(Expression) method of the IQueryProvider represented by the Provider property of the source parameter.

呼び出し元を表す式ツリーを実行した結果として発生するクエリの動作Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>)の型の実装によって異なります、sourceパラメーター。The query behavior that occurs as a result of executing an expression tree that represents calling Min<TSource,TResult>(IQueryable<TSource>, Expression<Func<TSource,TResult>>) depends on the implementation of the type of the source parameter. 想定される動作が呼び出されますselector内の各要素に対してsourceと最小値を返します。The expected behavior is that it invokes selector on each element in source and returns the minimum value.

Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>) Min<TSource>(IQueryable<TSource>)

ジェネリック型の最小値を返しますIQueryable<T>します。Returns the minimum value of a generic IQueryable<T>.

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static TSource Min(System::Linq::IQueryable<TSource> ^ source);
public static TSource Min<TSource> (this System.Linq.IQueryable<TSource> source);
static member Min : System.Linq.IQueryable<'Source> -> 'Source
<Extension()>
Public Function Min(Of TSource) (source As IQueryable(Of TSource)) As TSource

型パラメーター

TSource

source の要素の型。The type of the elements of source.

パラメーター

source
IQueryable<TSource>

最小値を決定する値のシーケンス。A sequence of values to determine the minimum of.

戻り値

TSource TSource TSource TSource

シーケンスの最小値。The minimum value in the sequence.

例外

次のコード例は、使用する方法を示しますMin<TSource>(IQueryable<TSource>)シーケンスの最小値を決定します。The following code example demonstrates how to use Min<TSource>(IQueryable<TSource>) to determine the minimum value in a sequence.

double[] doubles = { 1.5E+104, 9E+103, -2E+103 };

double min = doubles.AsQueryable().Min();

Console.WriteLine("The smallest number is {0}.", min);

/*
    This code produces the following output:

    The smallest number is -2E+103.
*/

Dim doubles() As Double = {1.5E+104, 9.0E+103, -2.0E+103}

Dim min As Double = doubles.AsQueryable().Min()

MsgBox(String.Format("The smallest number is {0}.", min))

'This code produces the following output:

'The smallest number is -2E+103.

注釈

Min<TSource>(IQueryable<TSource>)メソッドを生成、MethodCallExpression呼び出しを表すMin<TSource>(IQueryable<TSource>)として構築されたジェネリック メソッド自体。The Min<TSource>(IQueryable<TSource>) method generates a MethodCallExpression that represents calling Min<TSource>(IQueryable<TSource>) itself as a constructed generic method. これは、後、渡します、MethodCallExpressionExecute<TResult>(Expression)のメソッド、IQueryProviderによって表される、Providerのプロパティ、sourceパラメーター。It then passes the MethodCallExpression to the Execute<TResult>(Expression) method of the IQueryProvider represented by the Provider property of the source parameter.

呼び出し元を表す式ツリーを実行した結果として発生するクエリの動作Min<TSource>(IQueryable<TSource>)の型の実装によって異なります、sourceパラメーター。The query behavior that occurs as a result of executing an expression tree that represents calling Min<TSource>(IQueryable<TSource>) depends on the implementation of the type of the source parameter. 想定される動作では、最小値を返しますsourceします。The expected behavior is that it returns the minimum value in source.

適用対象