I have a class as follows:
Class Scan
Delivered As Boolean
ScanDate As Date
State As String
Facility As String
End Class
Then I create a list and populate it with views containing everything.
Dim Scans As New List(Of Scan)
I need to open a list to get various pieces of information. I would like to use LINQ for this. The problem is that for life I just do not understand. The syntax throws me off, the fact that the results are not very typed, throws me off, and the sample on the Internet is simplified or too complicated.
How could I
- Get a counter grouped by date, where Delivered = True
- Get a counter grouped by Facility, where Delivered = True
- Get the number of scans grouped by state, where Delivered = True
Then I want to use this in a For Each loop.
For Each result In GroupedResults
‘My Code
Next
Ideally, Id, as a result, should be strongly typed. Is it possible?
, ? -, , . .
EDIT:
. , , , , , , .
, spring - . .
, , /. , , ?
Class Scan
Delivered As Boolean
Scanned As Boolean
ScanDate As Date
State As String
Facility As String
End Class
1. Get a count of Delivered = True, a count of Scanned=True, grouped by Date
2. Get a count of Delivered = True, a count of Scanned=True, grouped by Facility
3. Get a count of Delivered = True, a count of Scanned=True, grouped by State
?
Edit:
! , :
Dim query = From r In scans _
Group r By r.ScanDate Into g = Group _
Select New With _
{g, .DeliveredCount = g.Count(Function(s) s.Delivered), .ScannedCount = g.Count(Function(s) s.Scanned)}
. , . "" , ( ?), - . . , , , - #. , LINQ . , - , , .