这是我的界面
interface IBase
{
string MvrId { get; set; }
string IndividualFullName { get; set; }
string FirstHospitalCaseNumber { get; set; }
}
我有一堂课
public class AddMedicineModel:IBase
{
private MedicalVarianceEntities DbCtx = new MedicalVarianceEntities();
public AddMedicineModel(int MvrId)
{
Mvr Mvr = DbCtx.Mvrs.Find(MvrId);
this.MvrId = Mvr.PKMvrId.ToString();//for display purposes
IndividualFullName = Mvr.IndividualLastName
+ ", "
+ Mvr.IndividualFirstName;
FirstHospitalCaseNumber = Mvr.CaseNumber.ToString();
}
//IBASE INTERFACE IMPLEMENTATION
public string MvrId { get; set; }
public string IndividualFullName { get; set; }
public string FirstHospitalCaseNumber { get; set; }
}
这是我的部分观点!注意我的部分视图未附加到我的 AddMedicineModel
因此,我不能将它与从 IBase 继承的其他模型重用。如何为许多模型制作可重用的局部视图。
@model MedicalVariance.Models.ViewModels.AddMedicineModel
@Html.DisplayFor(model => model.MvrId)
@Html.DisplayFor(model => model.IndividualFullName)
@Html.DisplayFor(model => model.FirstHospitalCaseNumber)