I have a simple query which joins on an in-memory list.
`var taxTableIds = taxTables.Select(a => new { TaxTableId = a.Id }).ToList();
var ttQueryable = _dbContext.FromLocalList(taxTableIds);
var taxBrackets = await (from tb in Retrieve<Data.Models.Tax.TaxBrackets>()
join tt in ttQueryable on tb.TaxTableId equals tt.TaxTableId
select tb)
.ToListAsync();
var taxBracketsPublish = taxBrackets.Select(a => new TaxBracketsPublish
{
PublishId = publishLog.Id,
StoreNumber = storeHelper.StoreNumber,
SatelliteNumber = storeHelper.SatelliteNumber,
Id = a.Id,
TableId = a.TaxTableId,
LeftValue = a.LeftValue,
RightValue = (decimal)a.RightValue,
TaxValue = a.TaxValue,
StartRepeat = a.StartRepeat,
RestaurantId = storeHelper.RestaurantId
}).ToList();
return taxBracketsPublish;`
However, I'm getting an "Incorrect syntax near 'LIMIT'.", which is strange, because I don't believe LIMIT syntax is even supported in T-SQL.
The query produced the LINQ does indeed have LIMIT syntax:
SELECT [tb].[Id], [tb].[LastModifiedByUserId], [tb].[LastModifiedDT], [tb].[LeftValue], [tb].[RightValue], [tb].[StartRepeat], [tb].[TaxTableId], [tb].[TaxValue], [tb].[TransactionId], [t].[TaxTableId] FROM [Tax].[TaxBrackets] AS [tb] INNER JOIN ( SELECT CAST([x].[long1] AS int) AS [TaxTableId] FROM ( SELECT * FROM (VALUES (NULL, NULL)) AS __gen_query_data__ (id, long1) LIMIT 0 ) AS [x] ) AS [t] ON [tb].[TaxTableId] = [t].[TaxTableId]
I suspect that the issue here (as opposed to in other instances where this same construction appears to work fine) is that the taxTables array has 0 entries.
I have a simple query which joins on an in-memory list.
`var taxTableIds = taxTables.Select(a => new { TaxTableId = a.Id }).ToList(); var ttQueryable = _dbContext.FromLocalList(taxTableIds);
However, I'm getting an "Incorrect syntax near 'LIMIT'.", which is strange, because I don't believe LIMIT syntax is even supported in T-SQL.
The query produced the LINQ does indeed have LIMIT syntax:
SELECT [tb].[Id], [tb].[LastModifiedByUserId], [tb].[LastModifiedDT], [tb].[LeftValue], [tb].[RightValue], [tb].[StartRepeat], [tb].[TaxTableId], [tb].[TaxValue], [tb].[TransactionId], [t].[TaxTableId] FROM [Tax].[TaxBrackets] AS [tb] INNER JOIN ( SELECT CAST([x].[long1] AS int) AS [TaxTableId] FROM ( SELECT * FROM (VALUES (NULL, NULL)) AS __gen_query_data__ (id, long1) LIMIT 0 ) AS [x] ) AS [t] ON [tb].[TaxTableId] = [t].[TaxTableId]
I suspect that the issue here (as opposed to in other instances where this same construction appears to work fine) is that the taxTables array has 0 entries.
Is there any way to work around this?