我每个类型的层次结构都有一个表。
有一个包含“更新”的表格,并且“Werte”与这些更新直接相关。 “Werte”(值)可以是不同的派生,例如data_bool或data_Int,因此这些“值”有多个表,这是图表:
当我现在做这样的事情时:
IQueryable<Wert> alleWerte = (from w in db.Werte
where w.UpdateID == 5
select w);
alleWerte.ToList();
执行此操作时,这是由此产生的查询:
SELECT
`UnionAll5`.`C1`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (@gp1) WHEN (`UnionAll5`.`C9` = 1) THEN (@gp2) WHEN (`UnionAll5`.`C10` = 1) THEN (@gp3) WHEN (`UnionAll5`.`C11` = 1) THEN (@gp4) WHEN (`UnionAll5`.`C12` = 1) THEN (@gp5) ELSE (@gp6) END AS `C2`,
`Extent7`.`UpdateID`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (`UnionAll5`.`C2`) WHEN (`UnionAll5`.`C9` = 1) THEN (NULL) WHEN (`UnionAll5`.`C10` = 1) THEN (NULL) WHEN (`UnionAll5`.`C11` = 1) THEN (NULL) WHEN (`UnionAll5`.`C12` = 1) THEN (NULL) END AS `C3`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (NULL) WHEN (`UnionAll5`.`C9` = 1) THEN (`UnionAll5`.`C3`) WHEN (`UnionAll5`.`C10` = 1) THEN (NULL) WHEN (`UnionAll5`.`C11` = 1) THEN (NULL) WHEN (`UnionAll5`.`C12` = 1) THEN (NULL) END AS `C4`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (NULL) WHEN (`UnionAll5`.`C9` = 1) THEN (NULL) WHEN (`UnionAll5`.`C10` = 1) THEN (`UnionAll5`.`C4`) WHEN (`UnionAll5`.`C11` = 1) THEN (NULL) WHEN (`UnionAll5`.`C12` = 1) THEN (NULL) END AS `C5`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (NULL) WHEN (`UnionAll5`.`C9` = 1) THEN (NULL) WHEN (`UnionAll5`.`C10` = 1) THEN (NULL) WHEN (`UnionAll5`.`C11` = 1) THEN (`UnionAll5`.`C5`) WHEN (`UnionAll5`.`C12` = 1) THEN (NULL) END AS `C6`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (NULL) WHEN (`UnionAll5`.`C9` = 1) THEN (NULL) WHEN (`UnionAll5`.`C10` = 1) THEN (NULL) WHEN (`UnionAll5`.`C11` = 1) THEN (NULL) WHEN (`UnionAll5`.`C12` = 1) THEN (`UnionAll5`.`C6`) END AS `C7`,
CASE WHEN (`UnionAll5`.`C8` = 1) THEN (NULL) WHEN (`UnionAll5`.`C9` = 1) THEN (NULL) WHEN (`UnionAll5`.`C10` = 1) THEN (NULL) WHEN (`UnionAll5`.`C11` = 1) THEN (NULL) WHEN (`UnionAll5`.`C12` = 1) THEN (NULL) ELSE (`UnionAll5`.`C7`) END AS `C8`,
`Extent7`.`WertArt_Id`
FROM ((SELECT
`UnionAll4`.`C1`,
`UnionAll4`.`C2`,
`UnionAll4`.`C3`,
`UnionAll4`.`C4`,
`UnionAll4`.`C5`,
`UnionAll4`.`C6`,
`UnionAll4`.`C7`,
`UnionAll4`.`C8`,
`UnionAll4`.`C9`,
`UnionAll4`.`C10`,
`UnionAll4`.`C11`,
`UnionAll4`.`C12`
FROM ((SELECT
`UnionAll3`.`C1`,
`UnionAll3`.`C2`,
`UnionAll3`.`C3`,
`UnionAll3`.`C4`,
`UnionAll3`.`C5`,
`UnionAll3`.`C6`,
`UnionAll3`.`C7`,
`UnionAll3`.`C8`,
`UnionAll3`.`C9`,
`UnionAll3`.`C10`,
`UnionAll3`.`C11`,
`UnionAll3`.`C12`
FROM ((SELECT
`UnionAll2`.`C1`,
`UnionAll2`.`C2`,
`UnionAll2`.`C3`,
`UnionAll2`.`C4`,
`UnionAll2`.`C5`,
`UnionAll2`.`C6`,
`UnionAll2`.`C7`,
`UnionAll2`.`C8`,
`UnionAll2`.`C9`,
`UnionAll2`.`C10`,
`UnionAll2`.`C11`,
`UnionAll2`.`C12`
FROM ((SELECT
`UnionAll1`.`Id` AS `C1`,
`UnionAll1`.`Data` AS `C2`,
`UnionAll1`.`C1` AS `C3`,
`UnionAll1`.`C2` AS `C4`,
`UnionAll1`.`C3` AS `C5`,
`UnionAll1`.`C4` AS `C6`,
`UnionAll1`.`C5` AS `C7`,
`UnionAll1`.`C6` AS `C8`,
`UnionAll1`.`C7` AS `C9`,
`UnionAll1`.`C8` AS `C10`,
`UnionAll1`.`C9` AS `C11`,
`UnionAll1`.`C10` AS `C12`
FROM ((SELECT
`Extent1`.`Id`,
`Extent1`.`Data`,
NULL AS `C1`,
NULL AS `C2`,
NULL AS `C3`,
NULL AS `C4`,
NULL AS `C5`,
1 AS `C6`,
0 AS `C7`,
0 AS `C8`,
0 AS `C9`,
0 AS `C10`
FROM `Data_Bools` AS `Extent1`) UNION ALL (SELECT
`Extent2`.`Id`,
NULL AS `C1`,
NULL AS `C2`,
NULL AS `C3`,
NULL AS `C4`,
NULL AS `C5`,
`Extent2`.`Data`,
0 AS `C6`,
0 AS `C7`,
0 AS `C8`,
0 AS `C9`,
0 AS `C10`
FROM `Data_Strings` AS `Extent2`)) AS `UnionAll1`) UNION ALL (SELECT
`Extent3`.`Id`,
NULL AS `C1`,
`Extent3`.`Data`,
NULL AS `C2`,
NULL AS `C3`,
NULL AS `C4`,
NULL AS `C5`,
0 AS `C6`,
1 AS `C7`,
0 AS `C8`,
0 AS `C9`,
0 AS `C10`
FROM `Data_ByteArrays` AS `Extent3`)) AS `UnionAll2`) UNION ALL (SELECT
`Extent4`.`Id`,
NULL AS `C1`,
NULL AS `C2`,
`Extent4`.`Data`,
NULL AS `C3`,
NULL AS `C4`,
NULL AS `C5`,
0 AS `C6`,
0 AS `C7`,
1 AS `C8`,
0 AS `C9`,
0 AS `C10`
FROM `Data_DateTimes` AS `Extent4`)) AS `UnionAll3`) UNION ALL (SELECT
`Extent5`.`Id`,
NULL AS `C1`,
NULL AS `C2`,
NULL AS `C3`,
`Extent5`.`Data`,
NULL AS `C4`,
NULL AS `C5`,
0 AS `C6`,
0 AS `C7`,
0 AS `C8`,
1 AS `C9`,
0 AS `C10`
FROM `Data_Floats` AS `Extent5`)) AS `UnionAll4`) UNION ALL (SELECT
`Extent6`.`Id`,
NULL AS `C1`,
NULL AS `C2`,
NULL AS `C3`,
NULL AS `C4`,
`Extent6`.`Data`,
NULL AS `C5`,
0 AS `C6`,
0 AS `C7`,
0 AS `C8`,
0 AS `C9`,
1 AS `C10`
FROM `Data_Ints` AS `Extent6`)) AS `UnionAll5` INNER JOIN `Werte` AS `Extent7` ON `UnionAll5`.`C1` = `Extent7`.`Id`
WHERE `Extent7`.`UpdateID` = @p__linq__0
我错了什么? :D
说真的可以解释一下吗?数据库中每种类型的表是否真的在做这个?