例如。
如果James,Joe和John访问了一家商店,我怎么能算出有多少人在循环中访问了这家商店,而不是3次显示数据。真的,我需要计算在那1家商店中有多少B.customer_name。因此,对于每个customer_name计算出现的次数。
For Each A As customer_service.customer_details In C.customers
Dim B As customer_service.customer = customer_dl.customer_details(A.customer_id)
display_customer.Text &= "<p>" & A.customer_shops & " " & B.customer_name & "</p>"
Next
答案 0 :(得分:0)
要自己获取每个客户,然后计算,您通常会使用GroupBy
将每个客户的数据放在一起,然后Count
来获取计数。
在C#中,类似于:
foreach (var customerVisits in C.customers.GroupBy(c => c.Name))
{
int visitCount = customerVisits.Count()
}