public class Product
{
public long ID { get; set; }
public string ProductName { get; set; }
[Navigation]
public virtual List<ProductTag>? RelationList { get; set; } = new();
}
public class ProductTag
{
public long ID { get; set; }
public long ProductID { get; set; }
[Navigation("ProductID")]
public Product Product { get; set; }
public long TagID { get; set; }
[Navigation("TagID")]
public Tag Tag { get; set; }
}
public class Tag
{
public long ID { get; set; }
public string TagName { get; set; }
[Navigation]
public virtual List<ProductTag>? RelationList { get; set; } = new();
}
var list = dbContext.Query().IncludeMany(a => a.RelationList).ThenInclude(a => a.Tag).ToList();
如上查询,如果中间表 ProductTag 没有对应的数据,则主表数据也不能查出。
var list = dbContext.Query().IncludeMany(a => a.RelationList).ThenInclude(a => a.Tag).ToList();
如上查询,如果中间表 ProductTag 没有对应的数据,则主表数据也不能查出。