C# LINQ和MYSQL不支持指定的方法

C# LINQ和MYSQL不支持指定的方法,c#,mysql,linq,C#,Mysql,Linq,我试着写一个LINQ查询,它会在一个地方给我所有的细节,我需要生产日期、员工姓名以及这个员工应该从工作中得到的钱。这就是我到目前为止所做的: var PrePerWorker = (from Production in context.production where Production.ProductionDate >= dtpStartDate.SelectedDate && Produc

我试着写一个LINQ查询,它会在一个地方给我所有的细节,我需要生产日期、员工姓名以及这个员工应该从工作中得到的钱。这就是我到目前为止所做的:

var PrePerWorker =
                    (from Production in context.production
                    where Production.ProductionDate >= dtpStartDate.SelectedDate && Production.ProductionDate <= dtpEndDate.SelectedDate

                    select new
                    {
                        Worker = 
                            (from Employee in context.employees
                             where Employee.ID == Production.EmpID
                            select Employee.FirstName).FirstOrDefault(),
                        DateOfProduction = Production.ProductionDate,
                        Total =
                            Production.Side == 1 ? Production.Amount * 
                            (from Product in context.products
                             where Product.ProductID == Production.ProductID
                             select Product.SideA).FirstOrDefault():
                             Production.Side == 2 ? Production.Amount * 
                            (from Product in context.products
                             where Product.ProductID == Production.ProductID
                             select Product.SideB).FirstOrDefault():
                             Production.Side == 3 ? Production.Amount * 
                            (from Product in context.products
                             where Product.ProductID == Production.ProductID
                             select Product.SideC).FirstOrDefault(): 0
                    }).GroupBy(x => x.DateOfProduction, x => x.Worker);
var预加工工=
(来自上下文中的生产)
其中Production.ProductionDate>=dtpStartDate.SelectedDate&&Production.ProductionDate x.DateOfProduction,x=>x.Worker);
当我运行此命令,然后尝试对结果进行迭代时,会出现一个错误,显示“不支持指定的方法”。

有人知道为什么吗?我该怎么解决这个问题呢?

我猜是第三级无法将运算符转换为SQL

,以便按所需的两列进行分组
GroupBy(x=>new{x.DateOfProduction,x.Worker})。你能解释一下你需要什么吗,因为你的linq对我来说太难了。

因为你的linq不能转换成mysql查询。你在这里的意思是什么“.GroupBy(x=>x.DateOfProduction,x=>x.Worker);”?那我该怎么办?我的意思是通过2个“列”进行分组,您可以有效地使用GroupBy,这显然是查询提供程序不支持的。当它说“指定的方法”时,我希望在某个地方指定了某个方法,是吗?(可能是内部异常?)不,没有,我在互联网上搜索了它这是内部异常。那么我能做什么才能得到最终结果?好的,我需要在一个表中显示所有工作人员的名字(因此从工作人员表中选择了名字),生产日期和他赚了多少钱取决于他工作的地点。然后我需要把它加起来,得到每个工人每天的总数,然后在报告中显示出来。我希望我说清楚,如果现在请让我知道。