shuxinqin / Chloe

A lightweight and high-performance Object/Relational Mapping(ORM) library for .NET --C#
https://github.com/shuxinqin/Chloe/wiki
MIT License
1.52k stars 455 forks source link

多对多查询时,中间关系表没数据时未能将主表数据查出bug #321

Closed shuxinqin closed 2 years ago

shuxinqin commented 2 years ago
    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 没有对应的数据,则主表数据也不能查出。