我有以下响应类:
public class PatientFindResponse : IHasResponseStatus
{
public class Patient
{
public int PeopleId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
public Patient Result { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
这是我的服务:
public class PatientFindService : IService
{
public ISessionFactory NHSessionFactory { get; set; }
public PatientFindService(ISessionFactory sessionFactory)
{
NHSessionFactory = sessionFactory;
}
public object Execute(PatientFind request)
{
using (var session = NHSessionFactory.OpenSession())
{
var result = session.Load<MyCompany.MyProduct.Entities.People>(request.PeopleId);
return new PatientFindResponse
{
Result = result.TranslateTo<PatientFindResponse.Patient>()
};
}
}
}
var 结果具有加载模型的数据,但是 translateTo 创建和对象,其中值全部为空,属性与我的模型中的名称相同,尽管我的 DTO 中没有包含我的所有属性模型,不确定这是否是 translateTo 不起作用的原因,我没有收到任何错误。
这是我的模型:
using System;
using System;
using System.Collections.Generic;
namespace MyCompany.MyProduct.Entities
{
[Serializable]
public partial class People
{
public People()
{
ShrEpisodes = new Iesi.Collections.Generic.HashedSet();
}
public virtual string AdvDirectives
{
get;
set;
}
public virtual DateTime? AdvDirectivesDate
{
get;
set;
}
public virtual DateTime? AllergyUpdatedDate
{
get;
set;
}
public virtual string AlternatePatientId
{
get;
set;
}
public virtual DateTime? ArchiveDate
{
get;
set;
}
public virtual string ArchivedInfo
{
get;
set;
}
public virtual string AuthorizationSignature
{
get;
set;
}
public virtual string BloodType
{
get;
set;
}
public virtual string BreakGlass
{
get;
set;
}
public virtual string Comment
{
get;
set;
}
public virtual short CompanyId
{
get;
set;
}
public virtual DateTime? Dor
{
get;
set;
}
public virtual string ExternalPatientId
{
get;
set;
}
public virtual DateTime? FamilyHistUpdated
{
get;
set;
}
public virtual string FirstName
{
get;
set;
}
public virtual int? GuarantorId
{
get;
set;
}
public virtual DateTime? HealthCareMaintenanceUpdatedDate
{
get;
set;
}
public virtual string IncludeInClergyList
{
get;
set;
}
public virtual string IncludeInDirectory
{
get;
set;
}
public virtual DateTime? LastInpatientAdmittedDate
{
get;
set;
}
public virtual DateTime? LastInpatientDischargedDate
{
get;
set;
}
public virtual string LastName
{
get;
set;
}
public virtual DateTime? LastOutpatientAdmittedDate
{
get;
set;
}
public virtual DateTime? LastTetanusDate
{
get;
set;
}
public virtual string LivingWill
{
get;
set;
}
public virtual DateTime? LivingWillDate
{
get;
set;
}
public virtual DateTime? MedicalHistUpdated
{
get;
set;
}
public virtual int? MedicalRecordNumber
{
get;
set;
}
public virtual DateTime? MedicationUpdated
{
get;
set;
}
public virtual int ModifiedBy
{
get;
set;
}
public virtual DateTime ModifiedOn
{
get;
set;
}
public virtual int? MothersPeopleId
{
get;
set;
}
public virtual int PeopleId
{
get;
set;
}
public virtual int? NkaEnteredBy
{
get;
set;
}
public virtual DateTime? NkaEnteredOn
{
get;
set;
}
public virtual int? NoInformation
{
get;
set;
}
public virtual string NoKnownAllergies
{
get;
set;
}
public virtual string NoKnownMedication
{
get;
set;
}
public virtual string NoKnownMedicationInformationSource
{
get;
set;
}
public virtual DateTime? NoKnownMedicationUpdated
{
get;
set;
}
public virtual string NoKnownProblem
{
get;
set;
}
public virtual string NoKnownProblemInformationSource
{
get;
set;
}
public virtual DateTime? NoKnownProblemUpdated
{
get;
set;
}
public virtual string NoMedicationHistoryAssessed
{
get;
set;
}
public virtual DateTime? ObstetricalHistoryUpdatedDate
{
get;
set;
}
public virtual DateTime? OnGoingProbUpdated
{
get;
set;
}
public virtual string OrganDonor
{
get;
set;
}
public virtual DateTime? OrgonDonorDate
{
get;
set;
}
public virtual string OtherPatientId
{
get;
set;
}
public virtual int? PatientId
{
get;
set;
}
public virtual string PatientPreference
{
get;
set;
}
public virtual string PatientRefusedSigning
{
get;
set;
}
public virtual string PersonName
{
get;
set;
}
public virtual int? PrimaryPharmacyId
{
get;
set;
}
public virtual int? PrimaryPhysicianId
{
get;
set;
}
public virtual DateTime? PrivacyNoticeDate
{
get;
set;
}
public virtual int? RcopiaId
{
get;
set;
}
public virtual DateTime? RcopiaLastUpdateDate
{
get;
set;
}
public virtual string Relationship
{
get;
set;
}
public virtual DateTime? SpouseDor
{
get;
set;
}
public virtual string Status
{
get;
set;
}
public virtual short? StorageLocationId
{
get;
set;
}
public virtual string UnableToReportMedication
{
get;
set;
}
public virtual string UnableToReportMedicationInformationSource
{
get;
set;
}
public virtual DateTime? UnableToReportMedicationUpdated
{
get;
set;
}
public virtual GlbPerson GlbPerson
{
get;
set;
}
public virtual Iesi.Collections.Generic.ISet ShrEpisodes
{
get;
set;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
return true;
return Equals(obj as People);
}
public virtual bool Equals(People obj)
{
if (obj == null) return false;
if (Equals(AdvDirectives, obj.AdvDirectives) == false) return false;
if (Equals(AdvDirectivesDate, obj.AdvDirectivesDate) == false) return false;
if (Equals(AllergyUpdatedDate, obj.AllergyUpdatedDate) == false) return false;
if (Equals(AlternatePatientId, obj.AlternatePatientId) == false) return false;
if (Equals(ArchiveDate, obj.ArchiveDate) == false) return false;
if (Equals(ArchivedInfo, obj.ArchivedInfo) == false) return false;
if (Equals(AuthorizationSignature, obj.AuthorizationSignature) == false) return false;
if (Equals(BloodType, obj.BloodType) == false) return false;
if (Equals(BreakGlass, obj.BreakGlass) == false) return false;
if (Equals(Comment, obj.Comment) == false) return false;
if (Equals(CompanyId, obj.CompanyId) == false) return false;
if (Equals(Dor, obj.Dor) == false) return false;
if (Equals(ExternalPatientId, obj.ExternalPatientId) == false) return false;
if (Equals(FamilyHistUpdated, obj.FamilyHistUpdated) == false) return false;
if (Equals(FirstName, obj.FirstName) == false) return false;
if (Equals(GuarantorId, obj.GuarantorId) == false) return false;
if (Equals(HealthCareMaintenanceUpdatedDate, obj.HealthCareMaintenanceUpdatedDate) == false) return false;
if (Equals(IncludeInClergyList, obj.IncludeInClergyList) == false) return false;
if (Equals(IncludeInDirectory, obj.IncludeInDirectory) == false) return false;
if (Equals(LastInpatientAdmittedDate, obj.LastInpatientAdmittedDate) == false) return false;
if (Equals(LastInpatientDischargedDate, obj.LastInpatientDischargedDate) == false) return false;
if (Equals(LastName, obj.LastName) == false) return false;
if (Equals(LastOutpatientAdmittedDate, obj.LastOutpatientAdmittedDate) == false) return false;
if (Equals(LastTetanusDate, obj.LastTetanusDate) == false) return false;
if (Equals(LivingWill, obj.LivingWill) == false) return false;
if (Equals(LivingWillDate, obj.LivingWillDate) == false) return false;
if (Equals(MedicalHistUpdated, obj.MedicalHistUpdated) == false) return false;
if (Equals(MedicalRecordNumber, obj.MedicalRecordNumber) == false) return false;
if (Equals(MedicationUpdated, obj.MedicationUpdated) == false) return false;
if (Equals(ModifiedBy, obj.ModifiedBy) == false) return false;
if (Equals(ModifiedOn, obj.ModifiedOn) == false) return false;
if (Equals(MothersPeopleId, obj.MothersPeopleId) == false) return false;
if (Equals(PeopleId, obj. PeopleId) == false) return false;
if (Equals(NkaEnteredBy, obj.NkaEnteredBy) == false) return false;
if (Equals(NkaEnteredOn, obj.NkaEnteredOn) == false) return false;
if (Equals(NoInformation, obj.NoInformation) == false) return false;
if (Equals(NoKnownAllergies, obj.NoKnownAllergies) == false) return false;
if (Equals(NoKnownMedication, obj.NoKnownMedication) == false) return false;
if (Equals(NoKnownMedicationInformationSource, obj.NoKnownMedicationInformationSource) == false) return false;
if (Equals(NoKnownMedicationUpdated, obj.NoKnownMedicationUpdated) == false) return false;
if (Equals(NoKnownProblem, obj.NoKnownProblem) == false) return false;
if (Equals(NoKnownProblemInformationSource, obj.NoKnownProblemInformationSource) == false) return false;
if (Equals(NoKnownProblemUpdated, obj.NoKnownProblemUpdated) == false) return false;
if (Equals(NoMedicationHistoryAssessed, obj.NoMedicationHistoryAssessed) == false) return false;
if (Equals(ObstetricalHistoryUpdatedDate, obj.ObstetricalHistoryUpdatedDate) == false) return false;
if (Equals(OnGoingProbUpdated, obj.OnGoingProbUpdated) == false) return false;
if (Equals(OrganDonor, obj.OrganDonor) == false) return false;
if (Equals(OrgonDonorDate, obj.OrgonDonorDate) == false) return false;
if (Equals(OtherPatientId, obj.OtherPatientId) == false) return false;
if (Equals(PatientId, obj.PatientId) == false) return false;
if (Equals(PatientPreference, obj.PatientPreference) == false) return false;
if (Equals(PatientRefusedSigning, obj.PatientRefusedSigning) == false) return false;
if (Equals(PersonName, obj.PersonName) == false) return false;
if (Equals(PrimaryPharmacyId, obj.PrimaryPharmacyId) == false) return false;
if (Equals(PrimaryPhysicianId, obj.PrimaryPhysicianId) == false) return false;
if (Equals(PrivacyNoticeDate, obj.PrivacyNoticeDate) == false) return false;
if (Equals(RcopiaId, obj.RcopiaId) == false) return false;
if (Equals(RcopiaLastUpdateDate, obj.RcopiaLastUpdateDate) == false) return false;
if (Equals(Relationship, obj.Relationship) == false) return false;
if (Equals(SpouseDor, obj.SpouseDor) == false) return false;
if (Equals(Status, obj.Status) == false) return false;
if (Equals(StorageLocationId, obj.StorageLocationId) == false) return false;
if (Equals(UnableToReportMedication, obj.UnableToReportMedication) == false) return false;
if (Equals(UnableToReportMedicationInformationSource, obj.UnableToReportMedicationInformationSource) == false) return false;
if (Equals(UnableToReportMedicationUpdated, obj.UnableToReportMedicationUpdated) == false) return false;
return true;
}
public override int GetHashCode()
{
int result = 1;
result = (result * 397) ^ (AdvDirectives != null ? AdvDirectives.GetHashCode() : 0);
result = (result * 397) ^ (AdvDirectivesDate != null ? AdvDirectivesDate.GetHashCode() : 0);
result = (result * 397) ^ (AllergyUpdatedDate != null ? AllergyUpdatedDate.GetHashCode() : 0);
result = (result * 397) ^ (AlternatePatientId != null ? AlternatePatientId.GetHashCode() : 0);
result = (result * 397) ^ (ArchiveDate != null ? ArchiveDate.GetHashCode() : 0);
result = (result * 397) ^ (ArchivedInfo != null ? ArchivedInfo.GetHashCode() : 0);
result = (result * 397) ^ (AuthorizationSignature != null ? AuthorizationSignature.GetHashCode() : 0);
result = (result * 397) ^ (BloodType != null ? BloodType.GetHashCode() : 0);
result = (result * 397) ^ (BreakGlass != null ? BreakGlass.GetHashCode() : 0);
result = (result * 397) ^ (Comment != null ? Comment.GetHashCode() : 0);
result = (result * 397) ^ CompanyId.GetHashCode();
result = (result * 397) ^ (Dor != null ? Dor.GetHashCode() : 0);
result = (result * 397) ^ (ExternalPatientId != null ? ExternalPatientId.GetHashCode() : 0);
result = (result * 397) ^ (FamilyHistUpdated != null ? FamilyHistUpdated.GetHashCode() : 0);
result = (result * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0);
result = (result * 397) ^ (GuarantorId != null ? GuarantorId.GetHashCode() : 0);
result = (result * 397) ^ (HealthCareMaintenanceUpdatedDate != null ? HealthCareMaintenanceUpdatedDate.GetHashCode() : 0);
result = (result * 397) ^ (IncludeInClergyList != null ? IncludeInClergyList.GetHashCode() : 0);
result = (result * 397) ^ (IncludeInDirectory != null ? IncludeInDirectory.GetHashCode() : 0);
result = (result * 397) ^ (LastInpatientAdmittedDate != null ? LastInpatientAdmittedDate.GetHashCode() : 0);
result = (result * 397) ^ (LastInpatientDischargedDate != null ? LastInpatientDischargedDate.GetHashCode() : 0);
result = (result * 397) ^ (LastName != null ? LastName.GetHashCode() : 0);
result = (result * 397) ^ (LastOutpatientAdmittedDate != null ? LastOutpatientAdmittedDate.GetHashCode() : 0);
result = (result * 397) ^ (LastTetanusDate != null ? LastTetanusDate.GetHashCode() : 0);
result = (result * 397) ^ (LivingWill != null ? LivingWill.GetHashCode() : 0);
result = (result * 397) ^ (LivingWillDate != null ? LivingWillDate.GetHashCode() : 0);
result = (result * 397) ^ (MedicalHistUpdated != null ? MedicalHistUpdated.GetHashCode() : 0);
result = (result * 397) ^ (MedicalRecordNumber != null ? MedicalRecordNumber.GetHashCode() : 0);
result = (result * 397) ^ (MedicationUpdated != null ? MedicationUpdated.GetHashCode() : 0);
result = (result * 397) ^ ModifiedBy.GetHashCode();
result = (result * 397) ^ ModifiedOn.GetHashCode();
result = (result * 397) ^ (MothersPeopleId != null ? MothersPeopleId.GetHashCode() : 0);
result = (result * 397) ^ PeopleId.GetHashCode();
result = (result * 397) ^ (NkaEnteredBy != null ? NkaEnteredBy.GetHashCode() : 0);
result = (result * 397) ^ (NkaEnteredOn != null ? NkaEnteredOn.GetHashCode() : 0);
result = (result * 397) ^ (NoInformation != null ? NoInformation.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownAllergies != null ? NoKnownAllergies.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownMedication != null ? NoKnownMedication.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownMedicationInformationSource != null ? NoKnownMedicationInformationSource.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownMedicationUpdated != null ? NoKnownMedicationUpdated.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownProblem != null ? NoKnownProblem.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownProblemInformationSource != null ? NoKnownProblemInformationSource.GetHashCode() : 0);
result = (result * 397) ^ (NoKnownProblemUpdated != null ? NoKnownProblemUpdated.GetHashCode() : 0);
result = (result * 397) ^ (NoMedicationHistoryAssessed != null ? NoMedicationHistoryAssessed.GetHashCode() : 0);
result = (result * 397) ^ (ObstetricalHistoryUpdatedDate != null ? ObstetricalHistoryUpdatedDate.GetHashCode() : 0);
result = (result * 397) ^ (OnGoingProbUpdated != null ? OnGoingProbUpdated.GetHashCode() : 0);
result = (result * 397) ^ (OrganDonor != null ? OrganDonor.GetHashCode() : 0);
result = (result * 397) ^ (OrgonDonorDate != null ? OrgonDonorDate.GetHashCode() : 0);
result = (result * 397) ^ (OtherPatientId != null ? OtherPatientId.GetHashCode() : 0);
result = (result * 397) ^ (PatientId != null ? PatientId.GetHashCode() : 0);
result = (result * 397) ^ (PatientPreference != null ? PatientPreference.GetHashCode() : 0);
result = (result * 397) ^ (PatientRefusedSigning != null ? PatientRefusedSigning.GetHashCode() : 0);
result = (result * 397) ^ (PersonName != null ? PersonName.GetHashCode() : 0);
result = (result * 397) ^ (PrimaryPharmacyId != null ? PrimaryPharmacyId.GetHashCode() : 0);
result = (result * 397) ^ (PrimaryPhysicianId != null ? PrimaryPhysicianId.GetHashCode() : 0);
result = (result * 397) ^ (PrivacyNoticeDate != null ? PrivacyNoticeDate.GetHashCode() : 0);
result = (result * 397) ^ (RcopiaId != null ? RcopiaId.GetHashCode() : 0);
result = (result * 397) ^ (RcopiaLastUpdateDate != null ? RcopiaLastUpdateDate.GetHashCode() : 0);
result = (result * 397) ^ (Relationship != null ? Relationship.GetHashCode() : 0);
result = (result * 397) ^ (SpouseDor != null ? SpouseDor.GetHashCode() : 0);
result = (result * 397) ^ (Status != null ? Status.GetHashCode() : 0);
result = (result * 397) ^ (StorageLocationId != null ? StorageLocationId.GetHashCode() : 0);
result = (result * 397) ^ (UnableToReportMedication != null ? UnableToReportMedication.GetHashCode() : 0);
result = (result * 397) ^ (UnableToReportMedicationInformationSource != null ? UnableToReportMedicationInformationSource.GetHashCode() : 0);
result = (result * 397) ^ (UnableToReportMedicationUpdated != null ? UnableToReportMedicationUpdated.GetHashCode() : 0);
return result;
}
}
}