I have following two entities Doctor(parent) and DoctorPayment(child)
one possible way is to take Doctor object in DoctorPayment entity and get through Doctor.Name
But I only need DoctorName not whole object in DoctorPayment that should be mapped by DoctorId
I have mentioned just few properties of Doctor entity but it have around 50 properties so I don't want to take Doctor object in DoctorPayment
public class Doctor
{
public int Id { get; set; }
public string Name { get; set; }
public string Designation { get; set; }
public int ModifiedBy { get; set; }
}
public class DoctorPayment
{
public int Id { get; set; }
public int DoctorId { get; set; }
public decimal Amount { get; set; }
public DateTime Date { get; set; }
public int ModifiedBy { get; set; }
public Doctor Doctor { get; set; } // a possible way to take Doctor object
}
This is Currently not Possible with Entity Framework.EF does Support Object Mapping Only.You can't Map Single Column using EF.
Only Posssible way is to Get Maping for Whole object i.e Doctor and then you can use EF select to get Name only i.e
var DoctorName=DoctorPayment.Doctor.Name
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments