Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体框架核心-为每行生成sql select_C#_Entity Framework Core - Fatal编程技术网

C# 实体框架核心-为每行生成sql select

C# 实体框架核心-为每行生成sql select,c#,entity-framework-core,C#,Entity Framework Core,我使用EF Core 1.1.2。我有这个疑问: var tmp = _context.Notes .Select(x => new { Note = x, CommentsCount = x.Comments.Count(y => y.Status == 1) }).ToList(); 我想对数据库进行一次查询,但每个注释都有很多查询: SELE

我使用EF Core 1.1.2。我有这个疑问:

var tmp = _context.Notes
            .Select(x => new
            {
                Note = x,
                CommentsCount = x.Comments.Count(y => y.Status == 1)
            }).ToList();
我想对数据库进行一次查询,但每个注释都有很多查询:

SELECT [x].[NoteId], [x].[Content], [x].[Title]
FROM [Notes] AS [x]

exec sp_executesql N'SELECT COUNT(*)
FROM [Comments] AS [y1]
WHERE ([y1].[Status] = 1) AND (@_outer_NoteId = [y1].[NoteId])',N'@_outer_NoteId int',@_outer_NoteId=13

exec sp_executesql N'SELECT COUNT(*)
FROM [Comments] AS [y1]
WHERE ([y1].[Status] = 1) AND (@_outer_NoteId = [y1].[NoteId])',N'@_outer_NoteId int',@_outer_NoteId=14

// and much more for each note

这是EF Core 1.1.2中的一个bug吗?

如何设置实体?fluent api或数据注释数据注释扫描您如何显示实体的设置?您的LINQ查询有效吗?是的(我会说这是非常基本的)。因此,是的,这是一个错误。