Function evaluation timed out error in Linq to Entity
I'm using framework 3.5. I have one group Linq syntax like below
var TmpClause = (from c in MES_WO_Tracking
join s in WorkOrders
on c.WoNo equals s.OrderNum
where s.Plant == "XX" && c.Shift != null
group new {
c.QtyComplete,
c.QtyScrap
}
by new
{
MRP = s.MRP_CTLR,
SeqNo = c.SeqNo,
TriggerSAP = c.TriggerSAP,
Shift = c.Shift
} into n
select new BkdKPIOutput
{
MRP = n.Key.MRP,
SeqNo = n.Key.SeqNo + n.Key.TriggerSAP,
Shift = n.Key.Shift,
OutputQty = n.Sum(c => c.QtyComplete.Value),
InputQty = n.Sum(c => c.QtyScrap.Value) + n.Sum(c => c.QtyComplete.Value)
});
It always give me the "Function evaluation timed out" error. But strang开发者_StackOverflow中文版e thing is that I check the native sql, it only spend 1 sec.
SELECT [t2].[MRP_CTLR] AS [MRP] ,
[t2].[SeqNo] + [t2].[TriggerSAP] AS [SeqNo] ,
[t2].[Shift] ,
[t2].[value] AS [OutputQty] ,
[t2].[value2] + [t2].[value3] AS [InputQty] FROM ( SELECT SUM([t0].[QtyComplete]) AS [value] ,
SUM([t0].[QtyScrap]) AS [value2] ,
SUM([t0].[QtyComplete]) AS [value3] ,
[t1].[MRP_CTLR] ,
[t0].[SeqNo] ,
[t0].[TriggerSAP] ,
[t0].[Shift]
FROM [MES_WO_Tracking] AS [t0]
INNER JOIN [WorkOrder] AS [t1] ON [t0].[WoNo] = [t1].[OrderNum]
WHERE ( [t1].[Plant] = 'XX' )
AND ( [t0].[Shift] IS NOT NULL )
GROUP BY [t1].[MRP_CTLR] ,
[t0].[SeqNo] ,
[t0].[TriggerSAP] ,
[t0].[Shift]
) AS [t2]
Does anyone know this? Very appreciate for your help.
Try first selecting all data into TmpClause then in another variable do the group clause on the TmpClause data. Although this is not Ideal it might help you find out what is causing the issue.
精彩评论