create table Item
(
Id int not null,
Data int,
constraint PkItems primary key (Id)
)
class Item
{
public int Id;
public int? Data;
}
using (var db = new DbManager())
{
var data = db.GetTable<Item>().GroupBy(i => 0).Select(i => new { Min = i.Min(j => j.Data), Max = i.Max(j => j.Data) }).FirstOrDefault();
}
Expected sql:
SELECT MIN(Item.Data), MAX(Item.Data)
FROM (SELECT 0 AS Id, Data FROM Item) AS Item
GROUP BY Item.Id
Generated sql (bad):
SELECT TOP 1
Min([selectParam].[Data]) as [c1],
Max([selectParam].[Data]) as [c2]
FROM
[Item] [selectParam]
GROUP BY
0
Expected sql:
Generated sql (bad):