0

I'm new to linq and I'm having trouble getting the correct syntax for this sql statement.

SELECT
    A.AssetName,
    B.MPercentage,
    B.OPercentage,
    B.IsStateDefault,
    D.ShortName
FROM [Core].[dbo].[Asset] A
FULL OUTER JOIN [Core].[dbo].[PayrollMarkup] B
ON A.PayrollMarkupID = B.PayrollMarkupID
FULL OUTER JOIN [Core].[dbo].[StatePayrollMarkup] C
ON B.PayrollMarkupID = C.PayrollMarkupID
FULL OUTER JOIN [Core].[dbo].[StateLookup] D
ON C.StateID = D.StateID
WHERE A.AssetName IS NOT null
Mithrilhall
  • 1,485
  • 8
  • 33
  • 52
  • I'm pretty sure LINQ doesn't have a full outer join. – cadrell0 Nov 20 '13 at 19:55
  • There are **[many](http://stackoverflow.com/questions/2085422/how-to-do-a-full-outer-join-in-linq) [ways](http://stackoverflow.com/questions/5489987/linq-full-outer-join)** of doing it. – AgentFire Nov 20 '13 at 19:56
  • Additionally, I don't think it is the correct solution here. if A.AssetName cannot be null, the first join should be a LEFT JOIN. Plus, performing the additional joins after the first will be difficult if no `Core` is found. What are you really trying to do? There is probably a better way in SQL and LINQ. – cadrell0 Nov 20 '13 at 19:58
  • I'm trying to get back a list of Assets with their MPercentage, OPercentage and the ShortName. If no PayrollMarkup, StatePayrollMarkup or StateLookup exist, I would still like the AssetName returned with null for the remaining values. – Mithrilhall Nov 20 '13 at 20:00
  • 2
    sounds like all of that should be left joins. – cadrell0 Nov 20 '13 at 20:02

0 Answers0