试图解决这个问题。即使它们实际上是相同的,似乎也无法将一个 num 分配给另一个。
无法将类型“Project.Models.Concern.YesNo”隐式转换为“Project.ViewModels.PatientConcernsViewModel.YesNo”。存在显式转换(您是否缺少演员表?)
public class Concern
{
public int ConcernID { get; set; }
public YesNo LifeExpectancy { get; set; }
public YesNo CollateralHistoryAvailable { get; set; }
public enum YesNo
{
Yes,
No
}
}
public class PatientConcernsViewModel
{
public int ConcernID { get; set; }
public YesNo LifeExpectancy { get; set; }
public YesNo CollateralHistoryAvailable { get; set; }
public enum YesNo
{
Yes,
No
}
}
// FROM WITHIN MY CONTROLLER
var concern = concernRepository.Find(id);
// load related assessment data
var assessment = assessmentRepository.Find(AssessmentID);
PatientConcernsViewModel patientConcernsViewModel = new PatientConcernsViewModel();
// BOTH LINES BELOW GENERATE ERRORS
patientConcernsViewModel.CollateralHistoryAvailable = concern.CollateralHistoryAvailable;
patientConcernsViewModel.LifeExpectancy = concern.LifeExpectancy;