如何在实体框架中包含类的任何属性?

How to include with any property of class in entity framework?

提问人:Mesut Kızılay 提问时间:11/1/2023 最后编辑:Svyatoslav DanylivMesut Kızılay 更新时间:11/2/2023 访问量:31

问:

public class City:IEntity
{
    public int ID { get; set; }
    public string ILKODU { get; set; }
    public string ILADI { get; set; }
}
        
public class Doctor : IEntity
{
    public int ID { get; set; }
    public string KIMLIKNO { get; set; }
    public string UNVANI { get; set; }
    public string ADSOYAD { get; set; }
    public int? UZMANLIK1ID { get; set; }
    public int? UZMANLIK2ID { get; set; }
    public int? UNITE1ID { get; set; }
    public int? UNITE2ID { get; set; }
    public int? UNITE3ID { get; set; }
    public int? BRICKID { get; set; }
    public string CEPTELEFONU { get; set; }
    public string EMAIL { get; set; }
    public string SABITELEFON { get; set; }
    public string? ILKODU { get; set; }
    public bool? AKTIF { get; set; }

    //public int? CITYID { get; set; }
    //[NotMapped]
    public virtual City? CITY { get; set; }
    public virtual Expertise? UZMANLIK1 { get; set; }
    public virtual Expertise? UZMANLIK2 { get; set; }
    public virtual Unit? UNITE1 { get; set; }
    public virtual Unit? UNITE2 { get; set; }
    public virtual Unit? UNITE3 { get; set; }
    public virtual Brick? BRICK { get; set; }
}
var result = await _doctorDal.GetAll(index: pageRequest.PageIndex,
        size: pageRequest.PageSize,
        include: d => d.Include(d => d.BRICK)
                    .Include(d => d.UZMANLIK1)
                    .Include(d => d.UZMANLIK2)
                    .Include(d => d.UNITE1)
                    .Include(d => d.UNITE2)
                    .Include(d => d.UNITE3));

我想使用从医生到城市的包含功能。但是我想对“ILKODU”进行包含操作,但我的sql表中没有字段,我想使用“ILKODU”进行连接。我该怎么办?

加入 entity-framework-core include relational-database net-7.0

评论


答: 暂无答案