Entity Framework 通过导航名称(字符串)进行核心预加载

Entity Framework Core eager loading by navigation name(string)

我有 2 个实体 类,如下所示:

public class Office
{
    public int Id { get; set; }
    public string Address { get; set; }
    public string Telephone { get; set; }
    public int CityId { get; set; }

    public City City { get; set; }
}

public class City
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int ProvinceId { get; set; }

    public Province Province { get; set; }
}

我知道我可以通过这些方式包含城市:

IQueryable<Office> offices = _context.Offices.Include(o => o.City);

//or

IQueryable<Office> offices = _context.Offices.Include("City");        

并包括省市:

IQueryable<Office> offices = _context.Offices.Include(o => o.City).ThenInclude(c=>c.Province);

我的问题是,有什么方法可以使用字符串参数来ThenInclude省份吗?类似于 Include("City.Province")ThenInclude("Province").

只需使用:

Include("City").Include("City.Province")