Queryable.Min 메서드

정의

오버로드

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>)

제네릭 IQueryable<T>의 최소값을 반환합니다.Returns the minimum value of a generic IQueryable<T>.

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);
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

시퀀스의 최소값입니다.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.  

설명

이 메서드에 형식 인수가 형식 중 하나인 형식의 매개 변수가 하나 이상 있습니다 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. 그런 다음 MethodCallExpression Execute<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>)

제네릭 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);
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

시퀀스의 최소값입니다.The minimum value in the sequence.

예외

source이(가) null인 경우source is null.

예제

다음 코드 예제에서는를 사용 하 여 시퀀스의 최소값을 확인 하는 방법을 보여 줍니다 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. 그런 다음 MethodCallExpression Execute<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.

적용 대상