the ef core linq expression
Code: Select all
dbContext.Class2.Where(two =>
two.Test &&
two.Threes.Any(three => three.Test && !three.IsDeleted ))
.Select(o =>
new {
o.OneId,
NoFours = o.Threes.Any(three =>
three.Test &&
!three.IsDeleted &&
!three.Fours.Any(four =>
!four.IsDeleted &&
four.Test &&
four.FiveId != null &&
!four.Five.IsDeleted))})
.ToList()
Code: Select all
SELECT "two"."OneId", CASE
WHEN (
SELECT CASE
WHEN EXISTS (
SELECT 1
FROM "Class3" "three0"
WHERE ((("three0"."Test" = 1) AND ("three0"."IsDeleted" = 0)) AND NOT EXISTS (
SELECT 1
FROM "Class4" "four"
LEFT JOIN "Class5" "four.Five" ON "four"."FiveId" = "four.Five"."Id"
WHERE (((("four"."IsDeleted" = 0) AND "four"."Test") AND "four"."FiveId" IS NOT NULL) AND ("four.Five"."IsDeleted" = 0)) AND "three0"."Id" = "four"."Class3Id")) AND "two"."Id" = "three0"."TwoId")
THEN 1 ELSE 0
END
FROM DUAL
) = True
THEN 1 ELSE 0
END AS "NoFours"
FROM "Class2" "two"
WHERE ("two"."Test" = 1) AND EXISTS (
SELECT 1
FROM "Class3" "three"
WHERE (("three"."Test" = 1) AND ("three"."IsDeleted" = 0)) AND "two"."Id" = "three"."TwoId")
First error in line 11:
WHERE (((("four"."IsDeleted" = 0) AND "four"."Test") AND "four"."FiveId" IS NOT NULL) AND ("four.Five"."IsDeleted" = 0)) AND "three0"."Id" = "four"."Class3Id")) AND "two"."Id" = "three0"."TwoId")
should be
WHERE (((("four"."IsDeleted" = 0) AND ("four"."Test" = 1)) AND "four"."FiveId" IS NOT NULL) AND ("four.Five"."IsDeleted" = 0)) AND "three0"."Id" = "four"."Class3Id")) AND "two"."Id" = "three0"."TwoId")
Second error in line 15:
FROM DUAL
) = True
THEN 1 ELSE 0
should be
FROM DUAL
) = 1
THEN 1 ELSE 0
Democode can be downloaded here