I have the following linq to entities query which throws an exception:
db.Forecasts
.Where(f => f.GeoNameID == point.ID)
.Where(x => EntityFunctions.AddMinutes(x.DateStamp, utcOffset) >= localTime)
.GroupBy(x => EntityFunctions.AddMinutes(x.DateStamp, utcOffset))
.Select(g => new
{
Date = g.Key,
MinTemperature = g.Select(x => x.Temperature).Min(),
MaxTemperature = g.Select(x => x.Temperature).Max(),
MinWindSpeed = g.Select(x => x.WindSpeed).Min(),
MaxWindSpeed = g.Select(x => x.WindSpeed).Max(),
Conditions = g.Select(x => x.Condition)
});
while the same query without the 'Conditions = g.Select(x => x.Condition)' part works fine.
I read up on the 'Unknown column' issue and found out that it was a known Connector/Net bug in previous versions so I tried this with all the combinations of EF 5 and EF 4.3.1 along with Connector/Net 6.5.4 and the beta Connector/Net 6.6.3. The previous bug pointed to groupby with sum so it is a little different than my issue. Is this a bug or just lack of proper error handling from the connector's part (i.e. this shouldnt work but it should catch it during the generation of the query and not at the database level)?
db.Forecasts
.Where(f => f.GeoNameID == point.ID)
.Where(x => EntityFunctions.AddMinutes(x.DateStamp, utcOffset) >= localTime)
.GroupBy(x => EntityFunctions.AddMinutes(x.DateStamp, utcOffset))
.Select(g => new
{
Date = g.Key,
MinTemperature = g.Select(x => x.Temperature).Min(),
MaxTemperature = g.Select(x => x.Temperature).Max(),
MinWindSpeed = g.Select(x => x.WindSpeed).Min(),
MaxWindSpeed = g.Select(x => x.WindSpeed).Max(),
Conditions = g.Select(x => x.Condition)
});
while the same query without the 'Conditions = g.Select(x => x.Condition)' part works fine.
I read up on the 'Unknown column' issue and found out that it was a known Connector/Net bug in previous versions so I tried this with all the combinations of EF 5 and EF 4.3.1 along with Connector/Net 6.5.4 and the beta Connector/Net 6.6.3. The previous bug pointed to groupby with sum so it is a little different than my issue. Is this a bug or just lack of proper error handling from the connector's part (i.e. this shouldnt work but it should catch it during the generation of the query and not at the database level)?