{"action":"created","issue":{"url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/10","repository_url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore","labels_url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/10/comments","events_url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/10/events","html_url":"https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/10","id":364756506,"node_id":"MDU6SXNzdWUzNjQ3NTY1MDY=","number":10,"title":"the subtraction has no operation with three params","user":{"login":"quan01994","id":20533465,"node_id":"MDQ6VXNlcjIwNTMzNDY1","avatar_url":"https://avatars3.githubusercontent.com/u/20533465?v=4","gravatar_id":"","url":"https://api.github.com/users/quan01994","html_url":"https://github.com/quan01994","followers_url":"https://api.github.com/users/quan01994/followers","following_url":"https://api.github.com/users/quan01994/following{/other_user}","gists_url":"https://api.github.com/users/quan01994/gists{/gist_id}","starred_url":"https://api.github.com/users/quan01994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quan01994/subscriptions","organizations_url":"https://api.github.com/users/quan01994/orgs","repos_url":"https://api.github.com/users/quan01994/repos","events_url":"https://api.github.com/users/quan01994/events{/privacy}","received_events_url":"https://api.github.com/users/quan01994/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-09-28T06:23:50Z","updated_at":"2018-09-29T02:49:55Z","closed_at":null,"author_association":"NONE","body":"````csharp\r\nusing (var db = new HYWCRMContext(ConnectionString))\r\n{\r\n    db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;\r\n\r\n    var grossProfitQry = from oi in db.OrderInfo\r\n        from gi in db.GoodsInfo.LeftJoin(g => g.GoodsCode == oi.GoodsCode)\r\n        where oi.OrderStatus == 0 && oi.MemberCardId == \"0415955923793\" && oi.SaleDate >= beginTime\r\n        group new { oi, gi } by Sql.DatePart(Sql.DateParts.Month, oi.SaleDate) into g\r\n        select new\r\n        {\r\n            Month = g.Key,\r\n            A = g.Sum(m => m.oi.SaleWay == \"A\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0) \r\n                - g.Sum(m => m.oi.SaleWay == \"B\" ? m.oi.SaleMoney - Sql.Abs(m.oi.SaleQnty) * Sql.Round(m.gi.SchemePrice, 2) : 0) ?? 0\r\n                - Sql.Abs(g.Sum(m => m.oi.SaleWay == \"C\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0)) ?? 0\r\n        };\r\n    var flowList = grossProfitQry.ToLinqToDB().ToList();\r\n    ConsoleList(flowList);\r\n\r\n    var tempgrossProfitQry = from oi in db.OrderInfo\r\n        from gi in db.GoodsInfo.LeftJoin(g => g.GoodsCode == oi.GoodsCode)\r\n        where oi.OrderStatus == 0 && oi.MemberCardId == \"0415955923793\" && oi.SaleDate >= beginTime\r\n        group new { oi, gi } by Sql.DatePart(Sql.DateParts.Month, oi.SaleDate) into g\r\n        select new\r\n        {\r\n            Month = g.Key,\r\n            A = g.Sum(m => m.oi.SaleWay == \"A\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0) ??0,\r\n            B = g.Sum(m => m.oi.SaleWay == \"B\" ? m.oi.SaleMoney - Sql.Abs(m.oi.SaleQnty) * Sql.Round(m.gi.SchemePrice, 2) : 0) ?? 0,\r\n            C = Sql.Abs(g.Sum(m => m.oi.SaleWay == \"C\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0)) ?? 0\r\n        };\r\n    var temp = tempgrossProfitQry.ToLinqToDB().ToList();\r\n    ConsoleList(temp);\r\n}\r\n````\r\nresult \r\n![image](https://user-images.githubusercontent.com/20533465/46191340-bc98b500-c329-11e8-9980-4650b52700ba.png)\r\n\r\n\r\nIt seems that in the first query, the subtraction has no operation.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/comments/425609861","html_url":"https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/10#issuecomment-425609861","issue_url":"https://api.github.com/repos/linq2db/linq2db.EntityFrameworkCore/issues/10","id":425609861,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTYwOTg2MQ==","user":{"login":"quan01994","id":20533465,"node_id":"MDQ6VXNlcjIwNTMzNDY1","avatar_url":"https://avatars3.githubusercontent.com/u/20533465?v=4","gravatar_id":"","url":"https://api.github.com/users/quan01994","html_url":"https://github.com/quan01994","followers_url":"https://api.github.com/users/quan01994/followers","following_url":"https://api.github.com/users/quan01994/following{/other_user}","gists_url":"https://api.github.com/users/quan01994/gists{/gist_id}","starred_url":"https://api.github.com/users/quan01994/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quan01994/subscriptions","organizations_url":"https://api.github.com/users/quan01994/orgs","repos_url":"https://api.github.com/users/quan01994/repos","events_url":"https://api.github.com/users/quan01994/events{/privacy}","received_events_url":"https://api.github.com/users/quan01994/received_events","type":"User","site_admin":false},"created_at":"2018-09-29T02:49:55Z","updated_at":"2018-09-29T02:49:55Z","author_association":"NONE","body":"It's my program.cs\r\n````csharp\r\n    internal class Program\r\n    {\r\n        private const string ConnectionString = \"connectionString\";\r\n        private static void Main(string[] args)\r\n        {\r\n            var serviceProvider = BuildDi();\r\n            var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();\r\n\r\n            var beginTime = new DateTime(2018, 4, 1);\r\n            var endTime = new DateTime(2018, 8, 30);\r\n            var empCodes = new List<string>\r\n            {\r\n                \"6005\",\"8003\"\r\n            };\r\n\r\n            using (var db = new HYWCRMContext(ConnectionString,loggerFactory))\r\n            {\r\n                db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;\r\n                LinqToDBForEFTools.Implementation = new MyImplDefault();\r\n\r\n                var grossProfitQry = from oi in db.OrderInfo\r\n                    from gi in db.GoodsInfo.LeftJoin(g => g.GoodsCode == oi.GoodsCode)\r\n                    where oi.OrderStatus == 0 && oi.MemberCardId == \"0415955923793\" && oi.SaleDate >= beginTime\r\n                    group new { oi, gi } by Sql.DatePart(Sql.DateParts.Month, oi.SaleDate) into g\r\n                    select new\r\n                    {\r\n                        Month = g.Key,\r\n                        A = g.Sum(m => m.oi.SaleWay == \"A\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0) \r\n                            - g.Sum(m => m.oi.SaleWay == \"B\" ? m.oi.SaleMoney - Sql.Abs(m.oi.SaleQnty) * Sql.Round(m.gi.SchemePrice, 2) : 0) ?? 0\r\n                            - Sql.Abs(g.Sum(m => m.oi.SaleWay == \"C\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0)) ?? 0\r\n                    };\r\n                var flowList = grossProfitQry.ToLinqToDB().ToList();\r\n                ConsoleList(flowList);\r\n\r\n                var tempgrossProfitQry = from oi in db.OrderInfo\r\n                    from gi in db.GoodsInfo.LeftJoin(g => g.GoodsCode == oi.GoodsCode)\r\n                    where oi.OrderStatus == 0 && oi.MemberCardId == \"0415955923793\" && oi.SaleDate >= beginTime\r\n                    group new { oi, gi } by Sql.DatePart(Sql.DateParts.Month, oi.SaleDate) into g\r\n                    select new\r\n                    {\r\n                        Month = g.Key,\r\n                        A = g.Sum(m => m.oi.SaleWay == \"A\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0),\r\n                        B = g.Sum(m => m.oi.SaleWay == \"B\" ? m.oi.SaleMoney - Sql.Abs(m.oi.SaleQnty) * Sql.Round(m.gi.SchemePrice, 2) : 0) ?? 0,\r\n                        C = Sql.Abs(g.Sum(m => m.oi.SaleWay == \"C\" ? m.oi.SaleMoney - m.oi.SaleQnty * Sql.Round(m.gi.SchemePrice, 2) : 0)) ?? 0\r\n                    };\r\n                var temp = tempgrossProfitQry.ToLinqToDB().ToList();\r\n                ConsoleList(temp);\r\n            }\r\n        }\r\n\r\n        private static IServiceProvider BuildDi()\r\n        {\r\n            var services = new ServiceCollection();\r\n            services.AddSingleton<ILoggerFactory, LoggerFactory>();\r\n            services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));\r\n            services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace));\r\n            var serviceProvider = services.BuildServiceProvider();\r\n            var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();\r\n            //configure NLog\r\n            loggerFactory.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true });\r\n            NLog.LogManager.LoadConfiguration(\"nlog.config\");\r\n            return serviceProvider;\r\n        }\r\n\r\n        public static void ConsoleList<T>(T list) where T : IList\r\n        {\r\n            foreach (var item in list)\r\n            {\r\n                var type = item.GetType();\r\n                if (type.IsValueType)\r\n                {\r\n                    Console.WriteLine(item);\r\n                }\r\n                else\r\n                {\r\n                    Console.WriteLine(JsonConvert.SerializeObject(item));\r\n                }\r\n            }\r\n        }\r\n    }\r\n````\r\n````\r\n2018/09/29 10:27:45.916|INFO|Entity Framework Core 2.1.2-rtm-30932 initialized 'HYWCRMContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: RowNumberPaging  |Microsoft.EntityFrameworkCore.Infrastructure|version=2.1.2-rtm-30932, contextType=HYWCRMContext, provider=Microsoft.EntityFrameworkCore.SqlServer, options=RowNumberPaging , EventId_Id=10403, EventId_Name=Microsoft.EntityFrameworkCore.Infrastructure.ContextInitialized, EventId=Microsoft.EntityFrameworkCore.Infrastructure.ContextInitialized\r\n2018/09/29 10:27:47.107|INFO|BeforeExecute\r\n--  SqlServer.2008\r\nDECLARE @beginTime DateTime2\r\nSET     @beginTime = '2018-04-01T00:00:00'\r\n\r\nSELECT\r\n\t[t2].[c1] as [c11],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'A'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), [t2].[SaleQnty]) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c2],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'B'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), Abs([t2].[SaleQnty])) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c3],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'C'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), [t2].[SaleQnty]) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c4]\r\nFROM\r\n\t(\r\n\t\tSELECT\r\n\t\t\tDatePart(Month, [t1].[SaleDate]) as [c1],\r\n\t\t\t[t1].[SaleWay],\r\n\t\t\t[t1].[SaleMoney],\r\n\t\t\t[t1].[SaleQnty],\r\n\t\t\t[g1].[SchemePrice]\r\n\t\tFROM\r\n\t\t\t[OrderInfo] [t1]\r\n\t\t\t\tLEFT JOIN [GoodsInfo] [g1] ON [g1].[GoodsCode] = [t1].[GoodsCode]\r\n\t\tWHERE\r\n\t\t\t[t1].[OrderStatus] = 0 AND [t1].[MemberCardId] = N'0415955923793' AND\r\n\t\t\t[t1].[SaleDate] >= @beginTime\r\n\t) [t2]\r\nGROUP BY\r\n\t[t2].[c1]\r\n |LinqToDB|EventId_Id=1, EventId_Name=, EventId=1\r\n2018/09/29 10:27:47.179|INFO|Query Execution Time (AfterExecute) : 00:00:00.0693244\r\n |LinqToDB|EventId_Id=2, EventId_Name=, EventId=2\r\n2018/09/29 10:27:47.233|INFO|Total Execution Time (Completed): 00:00:00.3354490. Rows Count: 6.\r\n |LinqToDB|EventId_Id=3, EventId_Name=, EventId=3\r\n2018/09/29 10:27:47.374|INFO|BeforeExecute\r\n--  SqlServer.2008\r\nDECLARE @beginTime DateTime2\r\nSET     @beginTime = '2018-04-01T00:00:00'\r\n\r\nSELECT\r\n\t[t2].[c1] as [c11],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'A'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), [t2].[SaleQnty]) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c2],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'B'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), Abs([t2].[SaleQnty])) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c3],\r\n\tSum(CASE\r\n\t\tWHEN [t2].[SaleWay] = N'C'\r\n\t\t\tTHEN [t2].[SaleMoney] - Convert(Decimal(29,10), [t2].[SaleQnty]) * Round([t2].[SchemePrice], 2)\r\n\t\tELSE 0\r\n\tEND) as [c4]\r\nFROM\r\n\t(\r\n\t\tSELECT\r\n\t\t\tDatePart(Month, [t1].[SaleDate]) as [c1],\r\n\t\t\t[t1].[SaleWay],\r\n\t\t\t[t1].[SaleMoney],\r\n\t\t\t[t1].[SaleQnty],\r\n\t\t\t[g1].[SchemePrice]\r\n\t\tFROM\r\n\t\t\t[OrderInfo] [t1]\r\n\t\t\t\tLEFT JOIN [GoodsInfo] [g1] ON [g1].[GoodsCode] = [t1].[GoodsCode]\r\n\t\tWHERE\r\n\t\t\t[t1].[OrderStatus] = 0 AND [t1].[MemberCardId] = N'0415955923793' AND\r\n\t\t\t[t1].[SaleDate] >= @beginTime\r\n\t) [t2]\r\nGROUP BY\r\n\t[t2].[c1]\r\n |LinqToDB|EventId_Id=4, EventId_Name=, EventId=4\r\n2018/09/29 10:27:47.374|INFO|Query Execution Time (AfterExecute) : 00:00:00.0049678\r\n |LinqToDB|EventId_Id=5, EventId_Name=, EventId=5\r\n2018/09/29 10:27:47.386|INFO|Total Execution Time (Completed): 00:00:00.0125142. Rows Count: 6.\r\n |LinqToDB|EventId_Id=6, EventId_Name=, EventId=6\r\n2018/09/29 10:27:47.386|DEBUG|'HYWCRMContext' disposed. |Microsoft.EntityFrameworkCore.Infrastructure|contextType=HYWCRMContext, EventId_Id=10407, EventId_Name=Microsoft.EntityFrameworkCore.Infrastructure.ContextDisposed, EventId=Microsoft.EntityFrameworkCore.Infrastructure.ContextDisposed\r\n````"}}
{"actor":{"display_login":"quan01994"}}