每次我包括孩子时,EF左连接表

时间:2017-04-10 16:14:53

标签: entity-framework asp.net-core entity-framework-core

我已经阅读了有关如何在EF Core中包含所有属性的一些主题。 我有这样的事情:

Sub Get_numbers()

'I have got 2 sheets
Dim WB_dest As Workbook
Dim WB_data As Workbook

'I need 3 worksheets
Dim path_sheet As Worksheet
Dim dest_sheet As Worksheet
Dim data_sheet As Worksheet

'Data worksheet's path
Dim path As String

'Counter
Dim i As Byte

path = "C:\Users\Holger\Documents\VBA\WB_data.xlsx"

'I run this sub from destination file sheet "PATH" which is already open
Set WB_dest = ThisWorkbook
Set path_sheet = WB_dest.Worksheets("Path")
Set dest_sheet = WB_dest.Worksheets("TO")

'I set worksheet from the Excel taht I do not need to open, just reading
Set WB_data = Workbooks.Open(path)
Set data_sheet = WB_data.Worksheets("FROM")

'Data sheet contains three numbers in the first column
'and destination sheet also contains only three numbers in the first coulm
'I would like to add data_sheet numbers after dest_sheet numbers

data_sheet.Range("A4:A6").Copy
dest_sheet.Range("A4").PasteSpecial xlPasteValues
'For i = 4 To 6
'    dest_sheet.Cells(i, 1) = data_sheet(i, 1)
'Next i

End Sub

每次包含Enterprice,entityframework都会创建一个新的左连接行。导致这样的事情:

_dbcontext.Transaction
.Include(x => x.Enterprise).ThenInclude(x => x.Manager)
.Include(x => x.Enterprise).ThenInclude(x=> x.Address)
.Include(x => x.Enterprise).ThenInclude(x=> x.Example)
...

关于我如何才能制作ef的任何建议只能加入我的Enterprise表一次?因为这不是进行数据库调用的一种很好的方式,并且会降低整个查询的速度。

1 个答案:

答案 0 :(得分:2)

public MyRepository(IConfiguration configuration) { _connectionString = $"{configuration["ConnectionString:MyConnectionString"]}"; } 重复是已知的EF核心问题。不幸的是,它没有在EF Core 1.1中修复。根据{{​​3}},问题已分配到JOIN里程碑,没有任何估计的发布日期。