- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我没想到会生成这样的查询...
让我们回去,如果我保留一个包含,查询看起来不错,它做了一个简单的左连接
查询:
using (var db = new Context())
{
var data = db.MainTables.Include(x => x.LookupTables)
.Where(d => d.MainId == 10)
.FirstOrDefault();
}
生成的 SQL:
Opened connection at 2014-05-12 17:37:10 -04:00
SELECT
[Project1].[MainId] AS [MainId],
[Project1].[C1] AS [C1],
[Project1].[LookupId] AS [LookupId]
FROM ( SELECT
[Limit1].[MainId] AS [MainId],
[Extent2].[LookupId] AS [LookupId],
CASE WHEN ([Extent2].[MainId] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1]
FROM (SELECT TOP (1) [Extent1].[MainId] AS [MainId]
FROM [dbo].[MainTable] AS [Extent1]
WHERE 10 = [Extent1].[MainId] ) AS [Limit1]
LEFT OUTER JOIN [dbo].[MainTable_LookupTable] AS [Extent2] ON [Limit1].[MainId] = [Extent2].[MainId]
) AS [Project1]
ORDER BY [Project1].[MainId] ASC, [Project1].[C1] ASC
-- Executing at 2014-05-12 17:37:11 -04:00
-- Completed in 11 ms with result: SqlDataReader
Closed connection at 2014-05-12 17:37:11 -04:00
如果我有多个,查询会变得像 UNION ALL 一样疯狂......
这是预期的行为吗?如果是,是否可以保留一个包含的行为,同时对所有包含使用多个简单的左连接?
型号:
查询:
using (var db = new Context())
{
var data = db.MainTables.Include(x => x.LookupTables)
.Include(x => x.MainTable_MoreData)
.Include(x => x.MaintTable_DataLookup)
.Include(x => x.MainTable_EvenMoreData)
.Where(d => d.MainId == 10)
.FirstOrDefault()
}
生成的 SQL:
Opened connection at 2014-05-12 18:00:56 -04:00
SELECT
[UnionAll3].[C2] AS [C1],
[UnionAll3].[C3] AS [C2],
[UnionAll3].[C4] AS [C3],
[UnionAll3].[C5] AS [C4],
[UnionAll3].[C6] AS [C5],
[UnionAll3].[C7] AS [C6],
[UnionAll3].[C8] AS [C7],
[UnionAll3].[C9] AS [C8],
[UnionAll3].[C10] AS [C9],
[UnionAll3].[C11] AS [C10],
[UnionAll3].[C12] AS [C11],
[UnionAll3].[C13] AS [C12],
[UnionAll3].[C1] AS [C13],
[UnionAll3].[C14] AS [C14],
[UnionAll3].[C15] AS [C15],
[UnionAll3].[C16] AS [C16],
[UnionAll3].[C17] AS [C17],
[UnionAll3].[C18] AS [C18],
[UnionAll3].[C19] AS [C19],
[UnionAll3].[C20] AS [C20],
[UnionAll3].[C21] AS [C21],
[UnionAll3].[C22] AS [C22],
[UnionAll3].[C23] AS [C23],
[UnionAll3].[C24] AS [C24],
[UnionAll3].[C25] AS [C25],
[UnionAll3].[C26] AS [C26],
[UnionAll3].[C27] AS [C27],
[UnionAll3].[C28] AS [C28],
[UnionAll3].[C29] AS [C29],
[UnionAll3].[C30] AS [C30],
[UnionAll3].[C31] AS [C31],
[UnionAll3].[C32] AS [C32],
[UnionAll3].[C33] AS [C33],
[UnionAll3].[C34] AS [C34],
[UnionAll3].[C35] AS [C35],
[UnionAll3].[C36] AS [C36],
[UnionAll3].[C37] AS [C37],
[UnionAll3].[C38] AS [C38],
[UnionAll3].[C39] AS [C39],
[UnionAll3].[C40] AS [C40],
[UnionAll3].[C41] AS [C41],
[UnionAll3].[C42] AS [C42],
[UnionAll3].[C43] AS [C43],
[UnionAll3].[C44] AS [C44],
[UnionAll3].[C45] AS [C45],
[UnionAll3].[C46] AS [C46],
[UnionAll3].[C47] AS [C47],
[UnionAll3].[C48] AS [C48],
[UnionAll3].[C49] AS [C49],
[UnionAll3].[C50] AS [C50],
[UnionAll3].[C51] AS [C51]
FROM (SELECT
[UnionAll2].[C1] AS [C1],
[UnionAll2].[C2] AS [C2],
[UnionAll2].[C3] AS [C3],
[UnionAll2].[C4] AS [C4],
[UnionAll2].[C5] AS [C5],
[UnionAll2].[C6] AS [C6],
[UnionAll2].[C7] AS [C7],
[UnionAll2].[C8] AS [C8],
[UnionAll2].[C9] AS [C9],
[UnionAll2].[C10] AS [C10],
[UnionAll2].[C11] AS [C11],
[UnionAll2].[C12] AS [C12],
[UnionAll2].[C13] AS [C13],
[UnionAll2].[C14] AS [C14],
[UnionAll2].[C15] AS [C15],
[UnionAll2].[C16] AS [C16],
[UnionAll2].[C17] AS [C17],
[UnionAll2].[C18] AS [C18],
[UnionAll2].[C19] AS [C19],
[UnionAll2].[C20] AS [C20],
[UnionAll2].[C21] AS [C21],
[UnionAll2].[C22] AS [C22],
[UnionAll2].[C23] AS [C23],
[UnionAll2].[C24] AS [C24],
[UnionAll2].[C25] AS [C25],
[UnionAll2].[C26] AS [C26],
[UnionAll2].[C27] AS [C27],
[UnionAll2].[C28] AS [C28],
[UnionAll2].[C29] AS [C29],
[UnionAll2].[C30] AS [C30],
[UnionAll2].[C31] AS [C31],
[UnionAll2].[C32] AS [C32],
[UnionAll2].[C33] AS [C33],
[UnionAll2].[C34] AS [C34],
[UnionAll2].[C35] AS [C35],
[UnionAll2].[C36] AS [C36],
[UnionAll2].[C37] AS [C37],
[UnionAll2].[C38] AS [C38],
[UnionAll2].[C39] AS [C39],
[UnionAll2].[C40] AS [C40],
[UnionAll2].[C41] AS [C41],
[UnionAll2].[C42] AS [C42],
[UnionAll2].[C43] AS [C43],
[UnionAll2].[C44] AS [C44],
[UnionAll2].[C45] AS [C45],
[UnionAll2].[C46] AS [C46],
[UnionAll2].[C47] AS [C47],
[UnionAll2].[C48] AS [C48],
[UnionAll2].[C49] AS [C49],
[UnionAll2].[C50] AS [C50],
[UnionAll2].[C51] AS [C51]
FROM (SELECT
[UnionAll1].[C1] AS [C1],
[UnionAll1].[MainId] AS [C2],
[UnionAll1].[MainId1] AS [C3],
[UnionAll1].[Field1] AS [C4],
[UnionAll1].[Field11] AS [C5],
[UnionAll1].[Field12] AS [C6],
[UnionAll1].[Field13] AS [C7],
[UnionAll1].[Field14] AS [C8],
[UnionAll1].[Field15] AS [C9],
[UnionAll1].[Field16] AS [C10],
[UnionAll1].[Field17] AS [C11],
[UnionAll1].[Field18] AS [C12],
[UnionAll1].[Field19] AS [C13],
[UnionAll1].[LookupId] AS [C14],
[UnionAll1].[Field161] AS [C15],
[UnionAll1].[Field151] AS [C16],
[UnionAll1].[Field141] AS [C17],
[UnionAll1].[Field131] AS [C18],
[UnionAll1].[Field121] AS [C19],
[UnionAll1].[Field111] AS [C20],
[UnionAll1].[Field110] AS [C21],
[UnionAll1].[C2] AS [C22],
[UnionAll1].[C3] AS [C23],
[UnionAll1].[C4] AS [C24],
[UnionAll1].[C5] AS [C25],
[UnionAll1].[C6] AS [C26],
[UnionAll1].[C7] AS [C27],
[UnionAll1].[C8] AS [C28],
[UnionAll1].[C9] AS [C29],
[UnionAll1].[C10] AS [C30],
[UnionAll1].[C11] AS [C31],
[UnionAll1].[C12] AS [C32],
[UnionAll1].[C13] AS [C33],
[UnionAll1].[C14] AS [C34],
[UnionAll1].[C15] AS [C35],
[UnionAll1].[C16] AS [C36],
[UnionAll1].[C17] AS [C37],
[UnionAll1].[C18] AS [C38],
[UnionAll1].[C19] AS [C39],
[UnionAll1].[C20] AS [C40],
[UnionAll1].[C21] AS [C41],
[UnionAll1].[C22] AS [C42],
[UnionAll1].[C23] AS [C43],
[UnionAll1].[C24] AS [C44],
[UnionAll1].[C25] AS [C45],
[UnionAll1].[C26] AS [C46],
[UnionAll1].[C27] AS [C47],
[UnionAll1].[C28] AS [C48],
[UnionAll1].[C29] AS [C49],
[UnionAll1].[C30] AS [C50],
[UnionAll1].[C31] AS [C51]
FROM (SELECT
CASE WHEN ([Join1].[MainId] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1],
[Limit1].[MainId] AS [MainId],
[Limit1].[MainId] AS [MainId1],
[Limit1].[Field1] AS [Field1],
[Limit1].[Field11] AS [Field11],
[Limit1].[Field12] AS [Field12],
[Limit1].[Field13] AS [Field13],
[Limit1].[Field14] AS [Field14],
[Limit1].[Field15] AS [Field15],
[Limit1].[Field16] AS [Field16],
[Limit1].[Field17] AS [Field17],
[Limit1].[Field18] AS [Field18],
[Limit1].[Field19] AS [Field19],
[Join1].[LookupId1] AS [LookupId],
[Join1].[Field16] AS [Field161],
[Join1].[Field15] AS [Field151],
[Join1].[Field14] AS [Field141],
[Join1].[Field13] AS [Field131],
[Join1].[Field12] AS [Field121],
[Join1].[Field11] AS [Field111],
[Join1].[Field1] AS [Field110],
CAST(NULL AS int) AS [C2],
CAST(NULL AS int) AS [C3],
CAST(NULL AS varchar(1)) AS [C4],
CAST(NULL AS varchar(1)) AS [C5],
CAST(NULL AS varchar(1)) AS [C6],
CAST(NULL AS varchar(1)) AS [C7],
CAST(NULL AS varchar(1)) AS [C8],
CAST(NULL AS varchar(1)) AS [C9],
CAST(NULL AS varchar(1)) AS [C10],
CAST(NULL AS int) AS [C11],
CAST(NULL AS varchar(1)) AS [C12],
CAST(NULL AS varchar(1)) AS [C13],
CAST(NULL AS varchar(1)) AS [C14],
CAST(NULL AS varchar(1)) AS [C15],
CAST(NULL AS varchar(1)) AS [C16],
CAST(NULL AS varchar(1)) AS [C17],
CAST(NULL AS varchar(1)) AS [C18],
CAST(NULL AS int) AS [C19],
CAST(NULL AS int) AS [C20],
CAST(NULL AS int) AS [C21],
CAST(NULL AS varchar(1)) AS [C22],
CAST(NULL AS varchar(1)) AS [C23],
CAST(NULL AS varchar(1)) AS [C24],
CAST(NULL AS varchar(1)) AS [C25],
CAST(NULL AS varchar(1)) AS [C26],
CAST(NULL AS varchar(1)) AS [C27],
CAST(NULL AS varchar(1)) AS [C28],
CAST(NULL AS varchar(1)) AS [C29],
CAST(NULL AS varchar(1)) AS [C30],
CAST(NULL AS int) AS [C31]
FROM (SELECT TOP (1) [Extent1].[MainId] AS [MainId], [Extent1].[Field1] AS [Field1], [Extent1].[Field11] AS [Field11], [Extent1].[Field12] AS [Field12], [Extent1].[Field13] AS [Field13], [Extent1].[Field14] AS [Field14], [Extent1].[Field15] AS [Field15], [Extent1].[Field16] AS [Field16], [Extent1].[Field17] AS [Field17], [Extent1].[Field18] AS [Field18], [Extent1].[Field19] AS [Field19]
FROM [dbo].[MainTable] AS [Extent1]
WHERE 10 = [Extent1].[MainId] ) AS [Limit1]
LEFT OUTER JOIN (SELECT [Extent2].[MainId] AS [MainId], [Extent3].[LookupId] AS [LookupId1], [Extent3].[Field16] AS [Field16], [Extent3].[Field15] AS [Field15], [Extent3].[Field14] AS [Field14], [Extent3].[Field13] AS [Field13], [Extent3].[Field12] AS [Field12], [Extent3].[Field11] AS [Field11], [Extent3].[Field1] AS [Field1]
FROM [dbo].[MainTable_LookupTable] AS [Extent2]
INNER JOIN [dbo].[LookupTable] AS [Extent3] ON [Extent3].[LookupId] = [Extent2].[LookupId] ) AS [Join1] ON [Limit1].[MainId] = [Join1].[MainId]
UNION ALL
SELECT
2 AS [C1],
[Limit2].[MainId] AS [MainId],
[Limit2].[MainId] AS [MainId1],
[Limit2].[Field1] AS [Field1],
[Limit2].[Field11] AS [Field11],
[Limit2].[Field12] AS [Field12],
[Limit2].[Field13] AS [Field13],
[Limit2].[Field14] AS [Field14],
[Limit2].[Field15] AS [Field15],
[Limit2].[Field16] AS [Field16],
[Limit2].[Field17] AS [Field17],
[Limit2].[Field18] AS [Field18],
[Limit2].[Field19] AS [Field19],
CAST(NULL AS int) AS [C2],
CAST(NULL AS varchar(1)) AS [C3],
CAST(NULL AS varchar(1)) AS [C4],
CAST(NULL AS varchar(1)) AS [C5],
CAST(NULL AS varchar(1)) AS [C6],
CAST(NULL AS varchar(1)) AS [C7],
CAST(NULL AS varchar(1)) AS [C8],
CAST(NULL AS varchar(1)) AS [C9],
[Extent5].[DataId] AS [DataId],
[Extent5].[MainId] AS [MainId2],
[Extent5].[SomeData] AS [SomeData],
[Extent5].[Field1] AS [Field110],
[Extent5].[Field11] AS [Field111],
[Extent5].[Field12] AS [Field121],
[Extent5].[Field13] AS [Field131],
[Extent5].[Field14] AS [Field141],
[Extent5].[Field15] AS [Field151],
CAST(NULL AS int) AS [C10],
CAST(NULL AS varchar(1)) AS [C11],
CAST(NULL AS varchar(1)) AS [C12],
CAST(NULL AS varchar(1)) AS [C13],
CAST(NULL AS varchar(1)) AS [C14],
CAST(NULL AS varchar(1)) AS [C15],
CAST(NULL AS varchar(1)) AS [C16],
CAST(NULL AS varchar(1)) AS [C17],
CAST(NULL AS int) AS [C18],
CAST(NULL AS int) AS [C19],
CAST(NULL AS int) AS [C20],
CAST(NULL AS varchar(1)) AS [C21],
CAST(NULL AS varchar(1)) AS [C22],
CAST(NULL AS varchar(1)) AS [C23],
CAST(NULL AS varchar(1)) AS [C24],
CAST(NULL AS varchar(1)) AS [C25],
CAST(NULL AS varchar(1)) AS [C26],
CAST(NULL AS varchar(1)) AS [C27],
CAST(NULL AS varchar(1)) AS [C28],
CAST(NULL AS varchar(1)) AS [C29],
CAST(NULL AS int) AS [C30]
FROM (SELECT TOP (1) [Extent4].[MainId] AS [MainId], [Extent4].[Field1] AS [Field1], [Extent4].[Field11] AS [Field11], [Extent4].[Field12] AS [Field12], [Extent4].[Field13] AS [Field13], [Extent4].[Field14] AS [Field14], [Extent4].[Field15] AS [Field15], [Extent4].[Field16] AS [Field16], [Extent4].[Field17] AS [Field17], [Extent4].[Field18] AS [Field18], [Extent4].[Field19] AS [Field19]
FROM [dbo].[MainTable] AS [Extent4]
WHERE 10 = [Extent4].[MainId] ) AS [Limit2]
INNER JOIN [dbo].[MainTable_MoreData] AS [Extent5] ON [Limit2].[MainId] = [Extent5].[MainId]) AS [UnionAll1]
UNION ALL
SELECT
3 AS [C1],
[Limit3].[MainId] AS [MainId],
[Limit3].[MainId] AS [MainId1],
[Limit3].[Field1] AS [Field1],
[Limit3].[Field11] AS [Field11],
[Limit3].[Field12] AS [Field12],
[Limit3].[Field13] AS [Field13],
[Limit3].[Field14] AS [Field14],
[Limit3].[Field15] AS [Field15],
[Limit3].[Field16] AS [Field16],
[Limit3].[Field17] AS [Field17],
[Limit3].[Field18] AS [Field18],
[Limit3].[Field19] AS [Field19],
CAST(NULL AS int) AS [C2],
CAST(NULL AS varchar(1)) AS [C3],
CAST(NULL AS varchar(1)) AS [C4],
CAST(NULL AS varchar(1)) AS [C5],
CAST(NULL AS varchar(1)) AS [C6],
CAST(NULL AS varchar(1)) AS [C7],
CAST(NULL AS varchar(1)) AS [C8],
CAST(NULL AS varchar(1)) AS [C9],
CAST(NULL AS int) AS [C10],
CAST(NULL AS int) AS [C11],
CAST(NULL AS varchar(1)) AS [C12],
CAST(NULL AS varchar(1)) AS [C13],
CAST(NULL AS varchar(1)) AS [C14],
CAST(NULL AS varchar(1)) AS [C15],
CAST(NULL AS varchar(1)) AS [C16],
CAST(NULL AS varchar(1)) AS [C17],
CAST(NULL AS varchar(1)) AS [C18],
[Extent7].[MainId] AS [MainId2],
[Extent7].[Data] AS [Data],
[Extent7].[Field1] AS [Field110],
[Extent7].[Field11] AS [Field111],
[Extent7].[Field12] AS [Field121],
[Extent7].[Field14] AS [Field141],
[Extent7].[Field15] AS [Field151],
[Extent7].[Field13] AS [Field131],
[Extent7].[MainId] AS [MainId3],
CAST(NULL AS int) AS [C19],
CAST(NULL AS int) AS [C20],
CAST(NULL AS varchar(1)) AS [C21],
CAST(NULL AS varchar(1)) AS [C22],
CAST(NULL AS varchar(1)) AS [C23],
CAST(NULL AS varchar(1)) AS [C24],
CAST(NULL AS varchar(1)) AS [C25],
CAST(NULL AS varchar(1)) AS [C26],
CAST(NULL AS varchar(1)) AS [C27],
CAST(NULL AS varchar(1)) AS [C28],
CAST(NULL AS varchar(1)) AS [C29],
CAST(NULL AS int) AS [C30]
FROM (SELECT TOP (1) [Extent6].[MainId] AS [MainId], [Extent6].[Field1] AS [Field1], [Extent6].[Field11] AS [Field11], [Extent6].[Field12] AS [Field12], [Extent6].[Field13] AS [Field13], [Extent6].[Field14] AS [Field14], [Extent6].[Field15] AS [Field15], [Extent6].[Field16] AS [Field16], [Extent6].[Field17] AS [Field17], [Extent6].[Field18] AS [Field18], [Extent6].[Field19] AS [Field19]
FROM [dbo].[MainTable] AS [Extent6]
WHERE 10 = [Extent6].[MainId] ) AS [Limit3]
INNER JOIN [dbo].[MaintTable_DataLookup] AS [Extent7] ON [Limit3].[MainId] = [Extent7].[MainId]) AS [UnionAll2]
UNION ALL
SELECT
4 AS [C1],
[Limit4].[MainId] AS [MainId],
[Limit4].[MainId] AS [MainId1],
[Limit4].[Field1] AS [Field1],
[Limit4].[Field11] AS [Field11],
[Limit4].[Field12] AS [Field12],
[Limit4].[Field13] AS [Field13],
[Limit4].[Field14] AS [Field14],
[Limit4].[Field15] AS [Field15],
[Limit4].[Field16] AS [Field16],
[Limit4].[Field17] AS [Field17],
[Limit4].[Field18] AS [Field18],
[Limit4].[Field19] AS [Field19],
CAST(NULL AS int) AS [C2],
CAST(NULL AS varchar(1)) AS [C3],
CAST(NULL AS varchar(1)) AS [C4],
CAST(NULL AS varchar(1)) AS [C5],
CAST(NULL AS varchar(1)) AS [C6],
CAST(NULL AS varchar(1)) AS [C7],
CAST(NULL AS varchar(1)) AS [C8],
CAST(NULL AS varchar(1)) AS [C9],
CAST(NULL AS int) AS [C10],
CAST(NULL AS int) AS [C11],
CAST(NULL AS varchar(1)) AS [C12],
CAST(NULL AS varchar(1)) AS [C13],
CAST(NULL AS varchar(1)) AS [C14],
CAST(NULL AS varchar(1)) AS [C15],
CAST(NULL AS varchar(1)) AS [C16],
CAST(NULL AS varchar(1)) AS [C17],
CAST(NULL AS varchar(1)) AS [C18],
CAST(NULL AS int) AS [C19],
CAST(NULL AS varchar(1)) AS [C20],
CAST(NULL AS varchar(1)) AS [C21],
CAST(NULL AS varchar(1)) AS [C22],
CAST(NULL AS varchar(1)) AS [C23],
CAST(NULL AS varchar(1)) AS [C24],
CAST(NULL AS varchar(1)) AS [C25],
CAST(NULL AS varchar(1)) AS [C26],
CAST(NULL AS int) AS [C27],
[Extent9].[LookupId] AS [LookupId],
[Extent9].[MainId] AS [MainId2],
[Extent9].[MoreMoreData] AS [MoreMoreData],
[Extent9].[Field17] AS [Field171],
[Extent9].[Field16] AS [Field161],
[Extent9].[Field15] AS [Field151],
[Extent9].[Field14] AS [Field141],
[Extent9].[Field13] AS [Field131],
[Extent9].[Field12] AS [Field121],
[Extent9].[Field11] AS [Field111],
[Extent9].[Field1] AS [Field110],
[Extent9].[MainId] AS [MainId3]
FROM (SELECT TOP (1) [Extent8].[MainId] AS [MainId], [Extent8].[Field1] AS [Field1], [Extent8].[Field11] AS [Field11], [Extent8].[Field12] AS [Field12], [Extent8].[Field13] AS [Field13], [Extent8].[Field14] AS [Field14], [Extent8].[Field15] AS [Field15], [Extent8].[Field16] AS [Field16], [Extent8].[Field17] AS [Field17], [Extent8].[Field18] AS [Field18], [Extent8].[Field19] AS [Field19]
FROM [dbo].[MainTable] AS [Extent8]
WHERE 10 = [Extent8].[MainId] ) AS [Limit4]
INNER JOIN [dbo].[MainTable_EvenMoreData] AS [Extent9] ON [Limit4].[MainId] = [Extent9].[MainId]) AS [UnionAll3]
ORDER BY [UnionAll3].[C3] ASC, [UnionAll3].[C1] ASC
-- Executing at 2014-05-12 18:00:57 -04:00
-- Completed in 39 ms with result: SqlDataReader
sql 服务器结果
2 行就够了,为什么要 8 行?
此数据库示例未使用索引等进行优化,但这是执行计划
理想情况下,我想生成一个看起来像这样的查询,同时保持 Entity Framework 跟踪更改,因为我将使用该对象来更新数据库
SELECT dbo.MainTable.MainId, dbo.MainTable.Field1, dbo.MainTable.Field11, dbo.MainTable.Field12, dbo.MainTable.Field13, dbo.MainTable.Field14,
dbo.MainTable.Field15, dbo.MainTable.Field16, dbo.MainTable.Field17, dbo.MainTable.Field18, dbo.MainTable.Field19, dbo.MainTable_EvenMoreData.LookupId,
dbo.MainTable_EvenMoreData.MainId AS Expr1, dbo.MainTable_EvenMoreData.MoreMoreData, dbo.MainTable_EvenMoreData.Field17 AS Expr2,
dbo.MainTable_EvenMoreData.Field16 AS Expr3, dbo.MainTable_EvenMoreData.Field15 AS Expr4, dbo.MainTable_EvenMoreData.Field14 AS Expr5,
dbo.MainTable_EvenMoreData.Field13 AS Expr6, dbo.MainTable_EvenMoreData.Field12 AS Expr7, dbo.MainTable_EvenMoreData.Field11 AS Expr8,
dbo.MainTable_EvenMoreData.Field1 AS Expr9, dbo.MainTable_LookupTable.MainId AS Expr10, dbo.MainTable_LookupTable.LookupId AS Expr11,
dbo.MainTable_MoreData.DataId, dbo.MainTable_MoreData.MainId AS Expr12, dbo.MainTable_MoreData.SomeData, dbo.MainTable_MoreData.Field1 AS Expr13,
dbo.MainTable_MoreData.Field11 AS Expr14, dbo.MainTable_MoreData.Field12 AS Expr15, dbo.MainTable_MoreData.Field13 AS Expr16,
dbo.MainTable_MoreData.Field14 AS Expr17, dbo.MainTable_MoreData.Field15 AS Expr18, dbo.MaintTable_DataLookup.MainId AS Expr19,
dbo.MaintTable_DataLookup.Data, dbo.MaintTable_DataLookup.Field1 AS Expr20, dbo.MaintTable_DataLookup.Field11 AS Expr21,
dbo.MaintTable_DataLookup.Field12 AS Expr22, dbo.MaintTable_DataLookup.Field14 AS Expr23, dbo.MaintTable_DataLookup.Field15 AS Expr24,
dbo.MaintTable_DataLookup.Field13 AS Expr25
FROM dbo.MainTable LEFT OUTER JOIN
dbo.MainTable_EvenMoreData ON dbo.MainTable.MainId = dbo.MainTable_EvenMoreData.MainId LEFT OUTER JOIN
dbo.MainTable_LookupTable ON dbo.MainTable.MainId = dbo.MainTable_LookupTable.MainId LEFT OUTER JOIN
dbo.MainTable_MoreData ON dbo.MainTable.MainId = dbo.MainTable_MoreData.MainId LEFT OUTER JOIN
dbo.MaintTable_DataLookup ON dbo.MainTable.MainId = dbo.MaintTable_DataLookup.MainId
WHERE dbo.MainTable.MainId = 10
最佳答案
所以在玩了几个小时之后,我在 sql server 上做了一些负载平衡/执行计划/统计,有一个简单的左连接和 Entity Framework 做的巨大查询。
Entity Framework 似乎大胜。
我将实现 .include() 解决方案。
关于c# - 在 Entity Framework 中使用 .include 创建巨大的查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23619402/
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicates: what is the difference between #include and #include “fi
我想使用 #include 指令,其文件名作为外部定义的宏传递。 例如 #include #FILE".h" 其中 FILE 将被定义为字符串 MyFile(不带引号),结果为 #include "M
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
我想在当前目录及其子目录下的每个 .m 文件中查找所有出现 ncread 的情况。我使用以下命令: grep -R --include="\.m" ncread . 但是该命令没有返回任何内容。 gr
有时我会遇到这样的情况,我发现我需要为大型第三方文件制作一个#include,这样我才能使用一个函数或一个小类,这让我感到内疚,因为我知道这已经消失了增加我的编译时间,因为当我只想要一个功能时它会编译
这个问题在这里已经有了答案: 关闭13年前. Possible Duplicate: what is the difference between #include and #include “fi
我正在尝试通过应用程序加载器提交应用程序。我收到这个错误。但我已经检查了build设置,所有三种架构都包含在有效架构设置中。 最佳答案 断开任何设备,只保留“iOS 设备”中的选项并将其存档。 关于i
Please check this demo plunker更好地理解我的问题。 在我的主页上有一个表格。每个表行后面都有一个最初隐藏的空行。单击第一行时,我使用指令在其下方的空行中注入(inject
我正在使用 mkdocs 创建 html 网页和片段扩展以将我的主文档分成小块。我有一个难以理解的错误: 在我制作的文件file1.md中: --8<-- includes/some_rep/frag
include的推荐方式是什么?您项目的所有文件? 我见过很多使用类似结构的例子: include 的有序列表单个顶级文件(定义 Module 的文件,或应用程序中的“主”文件)中的语句。 这似乎也是
我想知道如何使用 fx:include与 JavaFX Scene Builder 结合使用,因此: 想象我有一个 BorderPane (文件 borderpane.fxml)。在中间部分我想放一个
我看到 Fortran 有“调用”和“包含”语句。两者有什么区别? .i 文件类型有什么意义吗? 即: include 'somefile.i' call 'somesubroutine.f' 谢谢!
这很挑剔,可能没有任何实际用途。我只是好奇... 在 C++20 工作草案 (n4861) 中, header 名称定义为: (5.8) header-name: " q-char-
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: What is the difference between #include and #include “fil
我有一个非常庞大且臃肿的类,我想将它拆分成单独的文件,但它应该对用户完全透明并且与使用该类的现有项目兼容。 特别是,我有自己的 ImageMatrix 类,它定义了大量的一元函数、大量带有标量的二元函
我是 grep 的新手,在重构 C 和 C++ 文件的过程中,我遇到了替换系统的问题,包括 #include <>与本地包括 #include "" . 有没有一种方法可以将 grep 与任何替代工具
我正在制作一个 Spring MVC web 项目,我必须有一个常量 header 。 我的基本要求是“我们希望在所有屏幕上都有一个标题,以显示谁登录了 ProjectA。” 我从这里“What is
在 SWIG 中,“%include”指令与标准 C“#include”有什么区别? 例如,在所有教程中,为什么它们通常看起来像这样: %module my_module %{ #include "M
假设我们有这个头文件: MyClass.hpp #pragma once #include class MyClass { public: MyClass(double); /* .
我已经在一个项目上工作了一段时间,该项目实现了一个使用 C 库的自定义框架。该框架是用 Swift 编写的,我创建了一个模块来向 Swift 公开 C 头文件。该框架是在不同的项目中启动的,然后将该框
我是一名优秀的程序员,十分优秀!