[英]Specified method is not supported LINQ and MYSQL
I've tried to write a LINQ query that will give me all the details in one place, I need the date of production, the employee name and the sum of money this employee should get for his work. 我试图编写一个LINQ查询,该查询将在一个地方提供所有详细信息,我需要生产日期,员工姓名以及该员工应获得的工作收入。 this is what I have so far:
这是我到目前为止所拥有的:
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);
When I run this and then try to iterate over the results I get an error saying "Specified method is not supported". 当我运行此程序,然后尝试遍历结果时,出现错误消息“不支持指定的方法”。
Anyone knows why? 有人知道为什么吗? and how can I fix this?
我该如何解决?
My guess is that the tertiary ? 我的猜测是大专吗? : operator can't be translated to SQL
:运算符无法转换为SQL
For grouping by 2 columns you need GroupBy(x => new {x.DateOfProduction, x.Worker});
GroupBy(x => new {x.DateOfProduction, x.Worker});
2列分组,您需要GroupBy(x => new {x.DateOfProduction, x.Worker});
. 。 And can you explain what you need, because your linq looks like so hard for me.
而且您能解释一下您需要什么吗,因为您的linq对我来说很难。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.