{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/11317","repository_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/11317/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/11317/comments","events_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/11317/events","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/11317","id":306213414,"number":11317,"title":"Group By is getting an alias and causing a SQL Exception (in 2.1 Preview 1)","user":{"login":"joshuakent","id":117945,"avatar_url":"https://avatars2.githubusercontent.com/u/117945?v=4","gravatar_id":"","url":"https://api.github.com/users/joshuakent","html_url":"https://github.com/joshuakent","followers_url":"https://api.github.com/users/joshuakent/followers","following_url":"https://api.github.com/users/joshuakent/following{/other_user}","gists_url":"https://api.github.com/users/joshuakent/gists{/gist_id}","starred_url":"https://api.github.com/users/joshuakent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshuakent/subscriptions","organizations_url":"https://api.github.com/users/joshuakent/orgs","repos_url":"https://api.github.com/users/joshuakent/repos","events_url":"https://api.github.com/users/joshuakent/events{/privacy}","received_events_url":"https://api.github.com/users/joshuakent/received_events","type":"User","site_admin":false},"labels":[{"id":76481852,"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/labels/type-bug","name":"type-bug","color":"f7c6c7","default":false}],"state":"closed","locked":false,"assignee":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"assignees":[{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/37","html_url":"https://github.com/aspnet/EntityFrameworkCore/milestone/37","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/37/labels","id":3044062,"number":37,"title":"2.1.0","description":"","creator":{"login":"ajcvickers","id":1430078,"avatar_url":"https://avatars1.githubusercontent.com/u/1430078?v=4","gravatar_id":"","url":"https://api.github.com/users/ajcvickers","html_url":"https://github.com/ajcvickers","followers_url":"https://api.github.com/users/ajcvickers/followers","following_url":"https://api.github.com/users/ajcvickers/following{/other_user}","gists_url":"https://api.github.com/users/ajcvickers/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcvickers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcvickers/subscriptions","organizations_url":"https://api.github.com/users/ajcvickers/orgs","repos_url":"https://api.github.com/users/ajcvickers/repos","events_url":"https://api.github.com/users/ajcvickers/events{/privacy}","received_events_url":"https://api.github.com/users/ajcvickers/received_events","type":"User","site_admin":false},"open_issues":114,"closed_issues":183,"state":"open","created_at":"2018-01-17T21:48:56Z","updated_at":"2018-03-20T18:37:38Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-03-18T04:54:51Z","updated_at":"2018-03-20T18:37:38Z","closed_at":"2018-03-20T18:37:38Z","author_association":"NONE","body":"```C#\r\nvar test = _context.SystemStorefrontOrderLine.GroupBy(o => new { o.StorefrontId, o.OrderDate.Value.Date })\r\n                            .Select(g => new\r\n                            {\r\n                                g.Key.StorefrontId,\r\n                                Sum = g.Sum(o => o.OrderItemPrice),\r\n                                Min = g.Min(o => o.OrderItemPrice),\r\n                                Max = g.Max(o => o.OrderItemPrice),\r\n                                Avg = g.Average(o => o.OrderItemPrice)\r\n                            });\r\n```\r\ngenerates the following sql\r\n\r\n```sql\r\nSELECT [o].[StorefrontID], SUM([o].[OrderItemPrice]), MIN([o].[OrderItemPrice]), MAX([o].[OrderItemPrice]), AVG(CAST([o].[OrderItemPrice] AS decimal(18, 2)))\r\nFROM [SystemStorefrontOrderLine] AS [o]\r\nGROUP BY [o].[StorefrontID], CONVERT(date, [o].[OrderDate]) AS [Date]\r\n```\r\nwhere the AS [Date] is not valid SQL. This generates the following exception\r\n\r\n`System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'AS'.\r\n   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\r\n   at System.Data.SqlClient.SqlDataReader.get_MetaData()\r\n   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)\r\n   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)\r\n   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)\r\n`"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/comments/374710691","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/11317#issuecomment-374710691","issue_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/11317","id":374710691,"user":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"created_at":"2018-03-20T18:37:38Z","updated_at":"2018-03-20T18:37:38Z","author_association":"CONTRIBUTOR","body":"Generated SQL in nightly builds\r\n```SQL\r\n      SELECT [o].[StorefrontId], SUM([o].[OrderItemPrice]) AS [Sum], MIN([o].[OrderItemPrice]) AS [Min], MAX([o].[OrderItemPrice]) AS [Max], AVG(CAST([o].[OrderItemPrice] AS float)) AS [Avg]\r\n      FROM [SystemStorefrontOrderLine] AS [o]\r\n      GROUP BY [o].[StorefrontId], CONVERT(date, [o].[OrderDate])\r\n```\r\nDuplicate of #11218"}}
{"actor":{"display_login":"smitpatel"}}