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.
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(…) |
|
Herhangi bir |
Herhangi bir sýradaki öðeler bir koşulla eşleşmesi olup olmadığını belirler. |
Yoktur. |
Aggregate … In … Into Any() |
|
Contains |
Bir sıra belirtilen öğe içerip içermediğini belirler. |
Yoktur. |
Yoktur. |
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: Belirli bir Sözcükler Kümesini İçeren Cümleleri Sorgulama (LINQ)
Başvuru
Aggregate Tümcesi (Visual Basic)