如何将 PostgreSQL 查询转换为 Linq 到 NHibernate 的 SQL

How to convert PostgreSQL query to Linq to SQL for NHibernate

我正在使用 NHibernate 和 LINQ SQL,我想转换以下 SQL 查询:

select min(T."CustomerName") from public."Jobs" as T group by lower(T."CustomerName");

我想在 LINQ 中将其转换为 SQL 并将其添加到 DAO 中。

请帮忙。

终于找到答案了

这里是:

return HibernateTemplate.Execute(session => (from r in session.Query<Job>()
                                             group r by r.CustomerName.ToLower()
                                             into g
                                             let c = g.Min(l => l.CustomerName)
                                             orderby c
                                             select c)).ToList();

谢谢大家。