Cross apply in Linq
-
03-07-2019 - |
Question
Is it possible to use SQL Server 2008 CROSS APPLY with LINQ-2-SQL?
Example SQL:
select d.dateCol, tvf.descr, tvf.value
from dateTable d
cross apply tvFunction(d.dt, 'anotherParam') tvf
where d.category='someCat'
CROSS APPLY enables using values from a table (dateTable in the example) as parameters to a tablevalue function. This is very usefull if you need do do a complex calculation (encapsulated in a table value function) for a range of inputs.
Solution
The only way to use it would be to wrap the above code in a stored procedure and wrap it with LINQ to SQL.
OTHER TIPS
Try this:
from d in dateTable
from tvf in tvFunction(d.dt, 'anotherProgram')
where d.category = 'someCat'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow