/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_VBCSharp/VbLINQtoSQLHowTos/VB/Form6.vb
44 строки
2 KB
Next Turn
Format codes based on .editorconfig, Part 20 (#19005)
19 июн 2020, 16:57
Не верифицирован
19 июн 2020, 16:57
544f978
Код
Авторство
О чём код?
Public Class Form6 Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '<Snippet13> Dim db As New northwindDataContext Dim msg = "" Dim londonCustomerCount = Aggregate cust In db.Customers Where cust.City = "London" Into Count() msg &= "Count of London Customers: " & londonCustomerCount & vbCrLf Dim averageOrderCount = Aggregate cust In db.Customers Where cust.City = "London" Into Average(cust.Orders.Count) msg &= "Average number of Orders per customer: " & averageOrderCount & vbCrLf Dim venezuelaTotalOrders = Aggregate cust In db.Customers Where cust.Country = "Venezuela" Into Sum(cust.Orders.Count) msg &= "Total number of orders from Customers in Venezuela: " & venezuelaTotalOrders & vbCrLf MsgBox(msg) Dim averageCustomersByCity = From cust In db.Customers Group By cust.City Into Average(cust.Orders.Count) Order By Average DataGridView1.DataSource = averageCustomersByCity 'Another way to grab the count and sum londonCustomerCount = (From cust in db.Customers Where cust.City = "London").Count() venezuelaTotalOrders = (From cust in db.Customers Where cust.Country = "Venezuela" Select cust.Orders).Sum() '</Snippet13> End Sub End Class