FreeSql icon indicating copy to clipboard operation
FreeSql copied to clipboard

IncludeByPropertyName 二级加载

Open lhtuling opened this issue 3 years ago • 5 comments

    public class Lottery : EntyBase
    {
        public List<LotteryDetail> LotteryDetails { get; set; }
    }

    public class LotteryDetail : EntyBase
    {
        public int UserId { get; set; }
        public User User { get; set; }
    }

    _freeSql.Select<Lottery>()
    .IncludeByPropertyName("LotteryDetails")
    .IncludeByPropertyName("LotteryDetails.User")// 这样并不可以
    .ToListAsync();

文档没有查到相关信息 请问是否可以实现

lhtuling avatar Aug 11 '22 12:08 lhtuling

IncludeMany then 暂时不行,动态不好表示,明天研究下

2881099 avatar Aug 11 '22 14:08 2881099

好的大佬 我先用其他方式 期待好消息

lhtuling avatar Aug 11 '22 14:08 lhtuling

测试代码如下:

var tags3 = g.sqlserver.Select<Tag>()
    .IncludeMany(a => a.Tags,
        then => then.Include(a => a.Parent).IncludeMany(a => a.Songs).IncludeMany(a => a.Tags))
    .Include(a => a.Parent)
    .IncludeMany(a => a.Songs)
    .Where(a => a.Id == tag1.Id || a.Id == tag2.Id)
    .ToList();

var tags333 = g.sqlserver.Select<Tag>()
    .IncludeByPropertyName("Tags",
        then => then.IncludeByPropertyName("Parent").IncludeByPropertyName("Songs").IncludeByPropertyName("Tags"))
    .IncludeByPropertyName("Parent")
    .IncludeByPropertyName("Songs")
    .Where(a => a.Id == tag1.Id || a.Id == tag2.Id)
    .ToList();

2881099 avatar Aug 12 '22 03:08 2881099

v3.2.666-preview20220816 已发布

2881099 avatar Aug 12 '22 04:08 2881099

v3.2.666-preview20220816 已发布

大佬牛逼!我去试试

lhtuling avatar Aug 12 '22 05:08 lhtuling