我的查询类似于以下内容(postgresql)
SELECT split_part(grp.agerange, '*',2) as age_range,
round(sum(salary)) AS total
FROM
(
SELECT salary,
CASE
WHEN(date_part('year', age(birth_date)) > 0 AND date_part('year', age(birth_date)) <= 8) THEN '0 - 8 age'
WHEN(date_part('year', age(birth_date)) > 8 AND date_part('year', age(birth_date)) <= 16) THEN '8 - 16 age'
WHEN(date_part('year', age(birth_date)) > 16 AND date_part('year', age(birth_date)) <= 24) THEN '16 - 24 age'
WHEN(date_part('year', age(birth_date)) > 24) THEN '24 < age' ELSE 'Unknown'
END as agerange
FROM sde.employee
) grp
GROUP BY grp.agerange
ORDER BY grp.agerange;
我能否在Entity Framework Core 3.0的Employee模型中使用LINQ创建查询?
public class Employee{
public string Id {get;set;}
public string Name {get;set;}
public decimal Salary {get;set;}
public DateTime? BirthDate {get;set;}
}
根据我的数据库上下文:
var grouped = _context.Employees.Group(????
生日是可空类型。