public async Task<T> GetCountAsync<T>(List<int> ownerGroups,
List<string> vessels,
List<string> inspectionDateRanges,
string typeOfInspection )
{
//Final query that will be executed in SQL Server
string query = $"SELECT REPLACE(Risk, ' ', '_' ) AS Risk, COUNT(InspectionID) AS Count,
(COUNT(InspectionID) * 100.0) /
(SELECT COUNT(InspectionID) FROM [Inspection]
WHERE TypeOfInspection = 'SI' AND Risk IS NOT NULL) AS Percentage
FROM [Inspection]
WHERE TypeOfInspection = 'SI' AND
Risk IS NOT NULL AND
[OwnerGroup] IN (100, 80) AND
[Vessel] IN ('9939565', '9683415') AND
([DateOfInspection] BETWEEN '2024-01-01' AND '2024-12-31' OR
[DateOfInspection] BETWEEN '2023-01-01' AND '2024-12-31')
GROUP BY Risk;";
//Dapper code here
//Every conditions must be parameterized, no string interpolation
//inspectionDateRanges is a list of dates. There may be multiple pairs of date ranges
}