Code: Select all
var test = (from trans in sc.DB.PosTransaction.Where(p => p.TransDateTime >= model.StartDateTime
&& p.TransDateTime <= model.EndDateTime)
select new
{
PosTransID = trans.PosTransID,
ItemSummary = string.Join(", ", trans.PosTransItem.Select(p => p.Units.ToString() + "x" + p.ItemDesc)),
}).ToList();
In LinqToSQL this is the SQL that is created
Code: Select all
SELECT [t0].[PosTransID], ((CONVERT(NVarChar,[t1].[Units])) + @p2) + [t1].[ItemDesc] AS [value], (
SELECT COUNT(*)
FROM [dbo].[PosTransItem] AS [t2]
WHERE [t2].[PosTransID] = [t0].[PosTransID]
) AS [value2]
FROM [dbo].[PosTransaction] AS [t0]
LEFT OUTER JOIN [dbo].[PosTransItem] AS [t1] ON [t1].[PosTransID] = [t0].[PosTransID]
WHERE ([t0].[TransDateTime] >= @p0) AND ([t0].[TransDateTime] <= @p1)
ORDER BY [t0].[PosTransID], [t1].[PosItemID]
What is the suggested workaround for this one ? Create another query and create the string in the code ? It's getting pretty frustrating trying to move over to LinqConnect as a large proportion of our existing code seems to need to be rewritten. I appreciate that it's not the most performant SQL that is produced, but it currently works and we have had no issues with significant slowness of the app with the code as is.