0
如何將My LINQ轉換爲SQL?LINQ to SQL轉換器
我有這個LINQ聲明:
int LimCol = Convert.ToInt32(LimitColis);
result = oListTUP
.GroupBy(x => new { x.Item1, x.Item2, x.Item3, x.Item4, x.Item5 })
.Select(g => new
{
Key = g.Key,
Sum = g.Sum(x => x.Item6),
Poids = g.Sum(x => x.Item7),
})
.Select(p => new
{
Key = p.Key,
Items = Enumerable.Repeat(LimCol, p.Sum/LimCol).Concat(Enumerable.Repeat(p.Sum % LimCol, p.Sum % LimCol > 0 ? 1 : 0)),
CalculPoids = p.Poids/Enumerable.Repeat(LimCol, p.Sum/LimCol).Concat(Enumerable.Repeat(p.Sum % LimCol, p.Sum % LimCol > 0 ? 1 : 0)).Count()
})
.SelectMany(p => p.Items.Select(i => Tuple.Create(p.Key.Item1, p.Key.Item2, p.Key.Item3, p.Key.Item4, p.Key.Item5, i, p.CalculPoids)))
.ToList();
}
它運作良好,但不知爲何要推它,它變得太複雜了,所以我想將其轉換成純SQL。
我已經嘗試過SQL Profiler和LinqPad,但都沒有向我顯示SQL。
如何從My LINQ中查看SQL代碼?
預先感謝您。
SQL事件探查器不顯示對SQL服務器執行的命令?這聽起來不對。它顯示了什麼? – David
LinqPad肯定[顯示SQL生成](http://tenhundfeld.org/media/sql_to_sql.png) – Magnus
你一直在說「我的LINQ」 - 這是MySQL還是SQL Server? – Yuck