57
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
List<IncidentReport> incidentReports = new List<IncidentReport>
10
{
11
new IncidentReport { ReportID = 1, Region = "North", IncidentType = "Theft", Timestamp = new DateTime(2023, 3, 10), SeverityLevel = 3 },
12
new IncidentReport { ReportID = 2, Region = "South", IncidentType = "Vandalism", Timestamp = new DateTime(2023, 3, 11), SeverityLevel = 2 },
13
new IncidentReport { ReportID = 3, Region = "East", IncidentType = "Theft", Timestamp = new DateTime(2023, 3, 12), SeverityLevel = 4 },
14
new IncidentReport { ReportID = 4, Region = "West", IncidentType = "Arson", Timestamp = new DateTime(2023, 3, 13), SeverityLevel = 5 },
15
new IncidentReport { ReportID = 5, Region = "North", IncidentType = "Theft", Timestamp = new DateTime(2023, 3, 14), SeverityLevel = 4 },
16
// Additional incident report entries as needed
17
};
18
19
// Step 1: Calculate the total number of incidents and the average severity level for each incident type
20
var incidentStats = incidentReports
21
.GroupBy(ir => ir.IncidentType)
22
.Select(g => new
23
{
24
IncidentType = g.Key,
Cached Result
Total Qty 10 on Date 01/01/2017