何时使用IncludeinEF?投影中不需要? 您所在的位置:网站首页 juypter安装 何时使用IncludeinEF?投影中不需要?

何时使用IncludeinEF?投影中不需要?

2023-03-11 17:47| 来源: 网络整理| 查看: 265

我在Entity Framework Core中有以下内容:

public class Book { public Int32 Id { get; set; } public String Title { get; set; } public virtual Theme Theme { get; set; } } public class Theme { public Int32 Id { get; set; } public String Name { get; set; } public Byte[] Illustration { get; set; } public virtual ICollection Ebooks { get; set; } }

我有以下linq查询:

List books = await context.Books.Select(x => new BookModel { Id = x.Id, Name = x.Name, Theme = new ThemeModel { Id = x.Theme.Id, Name = x.Theme.Name } }).ToListAsync();

我不需要包含主题来完成这项工作,例如:

List books = await context.Books.Include(x => x.Theme).Select(x => ...

我什么时候需要在实体框架中使用Include?

UPDATE

我在主题中添加了一个Byte []插图类型的列.在我的预测中,我不包括该列,如果我使用Include,它会加载吗?或者永远不会加载,除非我在投影中有它?



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有