Aracılığıyla paylaş


Niceleyici İşlemleri

Nicelik belirteci işlemleri dönmek bir Boolean bazılarını veya tümünü bir sýradaki öðeler bir koşulla eşleşmesi olup olmadığını gösteren değer.

Aşağıdaki resimde iki farklı kaynak sıraları iki farklı nicelik belirteci işlemleri gösterir.Bir veya daha fazla büyük olan 'a' karakteri ve sonucu ilk operasyon ister true.İkinci işlem tüm öğelerini karakter 'a' olan ve sonuç ister true.

LINQ belirleyici işlemleri

Nicelik belirteci işlemleri standart sorgu işleci yöntemleri aşağıdaki bölümünde listelenir.

Yöntemler

Yöntem adı

Description

C# sorgu ifade sözdizimi

Visual BasicSorgu ifade sözdizimi

Daha Fazla Bilgi

Tümü

Bir sıradaki tüm öğeleri bir koşulla eşleşmesi olup olmadığını belirler.

Yoktur.

Aggregate … In … Into All(…)

Enumerable.All``1

Queryable.All``1

Herhangi bir

Herhangi bir sýradaki öðeler bir koşulla eşleşmesi olup olmadığını belirler.

Yoktur.

Aggregate … In … Into Any()

Enumerable.Any``1

Queryable.Any``1

Contains

Bir sıra belirtilen öğe içerip içermediğini belirler.

Yoktur.

Yoktur.

Enumerable.Contains``1

Queryable.Contains``1

Sorgu ifade sözdizimi örnekleri

Bu örnekler Aggregate yan tümcesinde Visual Basic filtre koşulu LINQ sorgu bir parçası olarak.

Aşağıdaki örnek Aggregate yan tümcesi ve All``1 , evcil hayvanlar, tüm belirtilen geçerlilik süresinden daha eski olan kişilerle bir derlemeden dönmek için uzantısı yöntemi.

Class Person
    Public Property Name As String 
    Public Property Pets As Pet()
End Class 

Class Pet
    Public Property Name As String 
    Public Property Age As Integer 
End Class 

Sub All()
    Dim barley As New Pet With {.Name = "Barley", .Age = 4}
    Dim boots As New Pet With {.Name = "Boots", .Age = 1}
    Dim whiskers As New Pet With {.Name = "Whiskers", .Age = 6}
    Dim bluemoon As New Pet With {.Name = "Blue Moon", .Age = 9}
    Dim daisy As New Pet With {.Name = "Daisy", .Age = 3}

    Dim charlotte As New Person With {.Name = "Charlotte", .Pets = New Pet() {barley, boots}}
    Dim arlene As New Person With {.Name = "Arlene", .Pets = New Pet() {whiskers}}
    Dim rui As New Person With {.Name = "Rui", .Pets = New Pet() {bluemoon, daisy}}

    ' Create the list of Person objects that will be queried. 
    Dim people As New System.Collections.Generic.List(Of Person)(New Person() {charlotte, arlene, rui})

    Dim query = From pers In people 
                Where (Aggregate pt In pers.Pets Into All(pt.Age > 2)) 
                Select pers.Name

    Dim sb As New System.Text.StringBuilder()
    For Each name As String In query
        sb.AppendLine(name)
    Next 

    ' Display the results.
    MsgBox(sb.ToString())

    ' This code produces the following output: 

    ' Arlene 
    ' Rui 

End Sub

Sonraki örnek Aggregate yan tümcesi ve Any``1 uzantısı yöntemi en az biri olan kişilerle pet bir derlemeden dönmek için belirtilen geçerlilik süresinden daha eski.

Class Person
    Public Property Name As String 
    Public Property Pets As Pet()
End Class 

Class Pet
    Public Property Name As String 
    Public Property Age As Integer 
End Class 

Sub Any()
    Dim barley As New Pet With {.Name = "Barley", .Age = 4}
    Dim boots As New Pet With {.Name = "Boots", .Age = 1}
    Dim whiskers As New Pet With {.Name = "Whiskers", .Age = 6}
    Dim bluemoon As New Pet With {.Name = "Blue Moon", .Age = 9}
    Dim daisy As New Pet With {.Name = "Daisy", .Age = 3}

    Dim charlotte As New Person With {.Name = "Charlotte", .Pets = New Pet() {barley, boots}}
    Dim arlene As New Person With {.Name = "Arlene", .Pets = New Pet() {whiskers}}
    Dim rui As New Person With {.Name = "Rui", .Pets = New Pet() {bluemoon, daisy}}

    ' Create the list of Person objects that will be queried. 
    Dim people As New System.Collections.Generic.List(Of Person)(New Person() {charlotte, arlene, rui})

    Dim query = From pers In people 
                Where (Aggregate pt In pers.Pets Into Any(pt.Age > 7)) 
                Select pers.Name

    Dim sb As New System.Text.StringBuilder()
    For Each name As String In query
        sb.AppendLine(name)
    Next 

    ' Display the results.
    MsgBox(sb.ToString())

    ' This code produces the following output: 

    ' Rui 

End Sub

Ayrıca bkz.

Görevler

Nasıl yapılır: Çalışma Zamanında Karşılaştırma Filtrelerini Dinamik Olarak Belirtme (C# Programlama Kılavuzu)

Nasıl yapılır: Belirli bir Sözcükler Kümesini İçeren Cümleleri Sorgulama (LINQ)

Başvuru

Aggregate Tümcesi (Visual Basic)

System.Linq

Kavramlar

Standart Sorgu İşleçlerine Genel Bakış