在entity framework core中,如果两个实体涉及到外键连接,查询的时候默认是只查自身而不会去查询外键表的。如果想要让查询结果包含外键实体,则需要使用include方法来让查询结果包含外键实体。如

_dbContext.ProductStandard.Include(o=>o.Product).SingleOrDefault(o => o.Id == id);

这个例子中,Product的Id和 ProductStandard的ProductId字段进行外键连接,想要让查询出来的productStandard携带 Product,则必须使用Include方法来进行声明。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2021-06-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-03-15
  • 2022-12-23
  • 2021-11-29
  • 2021-08-18
相关资源
相似解决方案