select
coalesce(x.value,a.default_value) as value
from table1 a
left outer join
(
select
b.configid,
b.value
from table2 b
join table3 c on b.dataid=c.id
where c.id=0
)x on a.id=x.configid
where a.key='abc'
Asked
Active
Viewed 45 times
-5
-
this might help https://stackoverflow.com/questions/296972/sql-to-linq-tool – dbajtr Nov 14 '17 at 13:32
-
1show us what have you tried and what problems you have.This isnt a `"do it for me"` site. – Juan Carlos Oropeza Nov 14 '17 at 13:36
1 Answers
0
For translating SQL to LINQ,
- Translate subselects as separate variables
- Translate each clause in LINQ clause order, leaving monadic operators (DISTINCT, TOP, etc) as functions applied to the whole LINQ query.
- Use table aliases as range variables. Use column aliases as anonymous type field names.
- Use anonymous types (new { }) for multiple columns
- Left Join is simulated by using a join variable and doing another from from the join variable followed by .DefaultIfEmpty().
- Replace
coalesce
with the conditional operator and a null test.

NetMage
- 26,163
- 3
- 34
- 55