本文介绍了包括一个集合,然后一个集合一级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

  public async任务< p>我正在尝试使用EF 7查询收集和子集合。列表<表>> GetAllTable(){
var tableList = await db.Tables.Include(o => o.Checks.Select(i => i.CheckItems))ToListAsync();
return tableList;

}

我按照这里的语法


您正在阅读的文档是EF 5。



设计会议笔记对于EF 7说,这个语法已经改变了 - 尝试这样:

  db.Tables.Include(t => t .Checks)
.ThenInclude(c => c.CheckItems)
.ToListAsync()


I am trying to query a collection and child collection using EF 7. Here's the code:

public async Task < List < Table >> GetAllTable() {
  var tableList = await db.Tables.Include(o => o.Checks.Select(i => i.CheckItems)).ToListAsync();
  return tableList;

}

I'm following the syntax from here MSDN. However, when i run this code i'm getting the following error. Does anyone know what went wrong here? Thanks!

解决方案

The documentation you are reading is for EF 5.

The design meeting notes for EF 7 say the syntax of this has changed - try this:

db.Tables.Include(t => t.Checks)
    .ThenInclude(c => c.CheckItems)
    .ToListAsync()

这篇关于包括一个集合,然后一个集合一级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-09 00:09