LINQ to SQL Converter
Posted
by
user609511
on Stack Overflow
See other posts from Stack Overflow
or by user609511
Published on 2011-11-28T17:44:31Z
Indexed on
2011/11/28
17:50 UTC
Read the original article
Hit count: 198
How can I convert My LINQ to SQL ?
i have this LINQ statement: 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();
}
It works well, but somehow want to push it and it become too complicated, so I want to convert it into Pure SQL.
I have tried SQL Profiler and LinqPad, but neither shows me the SQL.
How can I see the SQL code from My LINQ ?
Thank you in advance.
© Stack Overflow or respective owner