I am using a DB2 provider to hit a database on an AiX Server. Here is the LINQ statement I am using to that returns an anonymous type.
var docs = (from a in WIP
where (!dtFrom.HasValue && !dtTo.HasValue) || (a.QBE_DT.Value >= dtFrom.Value && a.QBE_DT.Value <= dtTo.Value) && a.STATUSCODE != "X" && a.KEY1 != "CABS" && a.KEY1 != "BPI"
group a by new
{
a.BATCH_ID,
a.POLICY_NUM,
a.QBE_DT
} into grp
select new
{
BatchId = grp.Key.BATCH_ID.Trim(),
BatchGroup = grp
}).ToList();
The return from this is causing the Provider to timeout, throwing a Process has been canceled due to an interrupt error. My thought is if I “Take” a subset of the recordset, this issue will go away. The issue I have, is I cannot simply add a Take(100) before the ToList(), because it throws:
SQL0418N A statement contains a use of an untyped parameter marker, the DEFAULT keyword, or a null value that is not valid. SQLSTATE=42610
I wish I was able to see the SQL generated to make sure it is the right syntax, but I don’t know how to in this situation. Is there an elegant way to get the first X Elements from above LINQ statement?
The workaround for this was to do the grouping and filtering in memory and getting a larger amount of data back from the source