Hi,

My linq query:
 
from result in results
group result by new
 {
          Year = result.Timestamp.Year,
          Month = result.Timestamp.Month,
          ResultId = result.Id
 }
 into g
 select new { g.Key.Year, g.Key.ResultId, MinMonth = g.Min(y => 
y.Timestamp.Month) };

generated sql:

select
        datepart(year, simplemeas0_.StartTime) as col_0_0_,
        datepart(month, simplemeas0_.StartTime) as col_1_0_,
        simplemeas0_.Id as col_2_0_, 
        datepart(year, simplemeas0_.StartTime) as col_3_0_,
        datepart(month, simplemeas0_.StartTime) as col_4_0_,
        simplemeas0_.Id as col_5_0_,
        cast(min(datepart(month, simplemeas0_.StartTime)) as INT) as 
col_6_0_ 
    from
        Measurement simplemeas0_ 
    group by
        datepart(year, simplemeas0_.StartTime) ,
        datepart(month, simplemeas0_.StartTime) ,
        simplemeas0_.Id

It generates correct sql if in the select is just new { g.Key }, instead of 
new { g.Key.Year, g.Key.ResultId }

Is it bug or there is a way to avoid duplication in sql select?  

Reply via email to