Have a working program that uses SQL queries to collect data. Working on converting to EF Core 8.
Found an online convert but the result will not compile in my C# project. Can someone convert this SQL to EF Core 8 query?:
SELECT DATEPART(mm, TSTAMP) AS Month, DATEPART(dd, TSTAMP) AS Day, DATEPART(hh, TSTAMP) AS Hour,
COUNT(CASE WHEN System=1 THEN CHANNEL END) "IPAPL 1 Processed",
max(CASE WHEN System=1 THEN [USED] END)as "IPAPL 1 MaxUsed",
COUNT(CASE WHEN System=2 THEN CHANNEL END) "IPAPL 2 Processed",
max(CASE WHEN System=2 THEN [USED] END)as "IPAPL 2 MaxUsed",
COUNT(CASE WHEN System=3 THEN CHANNEL END) "IPAPL 3 Processed",
max(CASE WHEN System=3 THEN [USED] END)as "IPAPL 3 MaxUsed",
COUNT(CASE WHEN System=4 THEN CHANNEL END) "IPAPL 4 Processed",
max(CASE WHEN System=4 THEN [USED] END)as "IPAPL 4 MaxUsed"
FROM [Customerdbchannels].[dbo].[TelematicPhysicalLines]
WHERE TSTAMP >= '2024-04-01' AND TSTAMP < '2024-07-01' AND STATUS <> 'free'
GROUP BY DATEPART(mm, TSTAMP), DATEPART(dd, TSTAMP), DATEPART(hour, TSTAMP)
ORDER By Month, Day, Hour;
I have the dbContext and the model class named TelematicPhysicalLine
.
Want the output/result to look like:
enter image description here