我正在尝试使用 Linq-to-NHibernate 获得以下 SQL 输出:
SELECT DISTINCT Name, at.Year FROM MyTable mt
INNER JOIN AnotherTable at ON at.Id = mt.AnotherTableId
Name 和 Year 属性将包含在一个新类中,因此 C# 代码将如下所示:
Session.Linq()
.Select(x => new FooBar { Name = x.Name, Year = x.AnotherTable.Year }))
.ToList();
如何让 DISTINCT 关键字出现在 sql 查询中?