Hi
I'm currently using the lastest version of ABP, I think its 5.1.
I have an existing entity called Practice which has an existing primary key called PracticeId. I want to inherit from AuditEntity to include the audit properties on the class and use the repositories in my application service to retrieve the data. What is the implementation that I should use in order to be able to add the audit properties and use the repositories without adding the id property to my class.
7 Answer(s)
-
0
Hi,
What is the
Practice
entity look like, can you share some code? -
0
Hi,
What is the
Practice
entity look like, can you share some code?Hi, Please find the class definition
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Volo.Abp.Auditing; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Auditing; namespace Blurush.Medistat.Domain { public partial class Practice { public Practice() { Accounts = new HashSet<Account>(); BulkClaimDetails = new HashSet<BulkClaimDetail>(); BulkClaimHeaders = new HashSet<BulkClaimHeader>(); CapitationFileImports = new HashSet<CapitationFileImport>(); Correspondences = new HashSet<Correspondence>(); CounsellingMessages = new HashSet<CounsellingMessage>(); Creditors = new HashSet<Creditor>(); DebtCollectors = new HashSet<DebtCollector>(); DesignatedServiceProviders = new HashSet<DesignatedServiceProvider>(); DiagnosisCodes = new HashSet<DiagnosisCode>(); Doctors = new HashSet<Doctor>(); EdiTransmissionBatches = new HashSet<EdiTransmissionBatch>(); EdidestinationConfigurations = new HashSet<EdidestinationConfiguration>(); EraglobalConfigurations = new HashSet<EraglobalConfiguration>(); GlobalTariffs = new HashSet<GlobalTariff>(); Invoices = new HashSet<Invoice>(); Laboratories = new HashSet<Laboratory>(); LogReportViews = new HashSet<LogReportView>(); LogTransactionTreatmentCodes = new HashSet<LogTransactionTreatmentCode>(); Macros = new HashSet<Macro>(); MedicalAidPackagePriceIncreases = new HashSet<MedicalAidPackagePriceIncrease>(); MedicalAidPmbexclusions = new HashSet<MedicalAidPmbexclusion>(); MedicalAidPriceIncreaseContracts = new HashSet<MedicalAidPriceIncreaseContract>(); MedicalAidPriceIncreases = new HashSet<MedicalAidPriceIncrease>(); MedicalAidTreatmentModifierOverrides = new HashSet<MedicalAidTreatmentModifierOverride>(); MedicalCertificates = new HashSet<MedicalCertificate>(); Modifiers = new HashSet<Modifier>(); PatientClinicalNotes = new HashSet<PatientClinicalNote>(); Patients = new HashSet<Patient>(); PracticeMedicalAidContracts = new HashSet<PracticeMedicalAidContract>(); PracticeMedicalAidPlanTypeTreatmentExclusions = new HashSet<PracticeMedicalAidPlanTypeTreatmentExclusion>(); PracticeMedicalAidPriceIncreaseContracts = new HashSet<PracticeMedicalAidPriceIncreaseContract>(); PracticeMedicalAidTreatmentPrices = new HashSet<PracticeMedicalAidTreatmentPrice>(); PracticeMedicalAidWebLogins = new HashSet<PracticeMedicalAidWebLogin>(); PracticeMedicalAids = new HashSet<PracticeMedicalAid>(); PracticeMemoSessions = new HashSet<PracticeMemoSession>(); PracticeMonthEndDateConfigurations = new HashSet<PracticeMonthEndDateConfiguration>(); PracticeMonthEndReports = new HashSet<PracticeMonthEndReport>(); PracticeMonthEndVatHistories = new HashSet<PracticeMonthEndVatHistory>(); PracticeSystemParameters = new HashSet<PracticeSystemParameter>(); Prescriptions = new HashSet<Prescription>(); ProcedureRequests = new HashSet<ProcedureRequest>(); Quotations = new HashSet<Quotation>(); Recalls = new HashSet<Recall>(); ReportParameterValues = new HashSet<ReportParameterValue>(); Scripts = new HashSet<Script>(); SystemParameterValues = new HashSet<SystemParameterValue>(); Tasks = new HashSet<Task>(); Transactions = new HashSet<Transaction>(); TransmissionSummaryLogs = new HashSet<TransmissionSummaryLog>(); TreatmentCodes = new HashSet<TreatmentCode>(); UserLoginHistories = new HashSet<UserLoginHistory>(); Vendors = new HashSet<Vendor>(); Depots = new HashSet<Depot>(); Icd10s = new HashSet<Icd10>(); MedicalAids = new HashSet<MedicalAid>(); MedicineMarkupStructures = new HashSet<MedicineMarkupStructure>(); PlaceOfServices = new HashSet<PlaceOfService>(); PlaceOfTreatments = new HashSet<PlaceOfTreatment>(); PriceIncreaseContracts = new HashSet<PriceIncreaseContract>(); Sms = new HashSet<Sms>(); Terms = new HashSet<Term>(); } public int PracticeId { get; set; } public int? MedicalAidBankId { get; set; } public int? PatientBankId { get; set; } public int? WcaBankId { get; set; } public int? OtherBankId { get; set; } public int? MedicalAidBankAccountTypeId { get; set; } public int? PatientBankAccountTypeId { get; set; } public int? WcaBankAccountTypeId { get; set; } public int? OtherBankAccountTypeId { get; set; } public int? PracticeTypeId { get; set; } public int? PostalCodeId { get; set; } public int? PhysicalPostalCodeId { get; set; } public int? PracticeNumber { get; set; } public string Surname { get; set; } public string Initials { get; set; } public string Name { get; set; } public string Title { get; set; } public string RegistrationNumber { get; set; } public string VatNumber { get; set; } public string PhysicalAddressLine1 { get; set; } public string PhysicalAddressLine2 { get; set; } public string PhysicalAddressLine3 { get; set; } public string PhysicalAddressLine4 { get; set; } public string PostalAddressLine1 { get; set; } public string PostalAddressLine2 { get; set; } public string PostalAddressLine3 { get; set; } public string PostalAddressLine4 { get; set; } public string AccountNumber1 { get; set; } public string BranchCode1 { get; set; } public string BranchName1 { get; set; } public string SwiftCode1 { get; set; } public string AccountNumber2 { get; set; } public string BranchCode2 { get; set; } public string BranchName2 { get; set; } public string SwiftCode2 { get; set; } public string AccountNumber3 { get; set; } public string BranchCode3 { get; set; } public string BranchName3 { get; set; } public string SwiftCode3 { get; set; } public string AccountNumber4 { get; set; } public string BranchCode4 { get; set; } public string BranchName4 { get; set; } public string SwiftCode4 { get; set; } public string HomeTelephone { get; set; } public string WorkTelephone { get; set; } public string MobileTelephone { get; set; } public string FaxNumber { get; set; } public string PagerNumber { get; set; } public string EmergencyNumber { get; set; } public string EmailAddress { get; set; } public string EmailAddress2 { get; set; } public string EmailAddress3 { get; set; } public string EmailAddressDayEnd { get; set; } public DateTime? JoinDate { get; set; } public string SwitchSourceId { get; set; } public string SwitchSourcePassword { get; set; } public string SwitchIpaddress { get; set; } public int? SwitchPort { get; set; } public short? SwitchFeedbackInterval { get; set; } public bool? IsCommunicationsActive { get; set; } public string TermsAndConditions { get; set; } public string BillingPolicy { get; set; } public double? Pf { get; set; } public bool IsLiveSwitchEdi { get; set; } public bool? IsAutomatedMonthEndActive { get; set; } public bool? IsAutomatedMonthEndEmailActive { get; set; } public bool IsMedpraxActive { get; set; } public bool? IsDayEndReportToBeEmailed { get; set; } public bool IsPrivate { get; set; } public bool IsExternalSmsAllowed { get; set; } [ForeignKey("MedicalAidBankId")] public virtual Bank MedicalAidBank { get; set; } [ForeignKey("MedicalAidBankAccountTypeId")] public virtual BankAccountType MedicalAidBankAccountType { get; set; } [ForeignKey("OtherBankId")] public virtual Bank OtherBank { get; set; } [ForeignKey("OtherBankAccountTypeId")] public virtual BankAccountType OtherBankAccountType { get; set; } [ForeignKey("PatientBankId")] public virtual Bank PatientBank { get; set; } [ForeignKey("PatientBankAccountTypeId")] public virtual BankAccountType PatientBankAccountType { get; set; } [ForeignKey("PhysicalPostalCodeId")] public virtual PostalCode PhysicalPostalCode { get; set; } [ForeignKey("PostalCodeId")] public virtual PostalCode PostalCode { get; set; } public virtual PracticeType PracticeType { get; set; } [ForeignKey("WcaBankId")] public virtual Bank WcaBank { get; set; } [ForeignKey("WcaBankAccountTypeId")] public virtual BankAccountType WcaBankAccountType { get; set; } public virtual ICollection<Account> Accounts { get; set; } public virtual ICollection<BulkClaimDetail> BulkClaimDetails { get; set; } public virtual ICollection<BulkClaimHeader> BulkClaimHeaders { get; set; } public virtual ICollection<CapitationFileImport> CapitationFileImports { get; set; } public virtual ICollection<Correspondence> Correspondences { get; set; } public virtual ICollection<CounsellingMessage> CounsellingMessages { get; set; } public virtual ICollection<Creditor> Creditors { get; set; } public virtual ICollection<DebtCollector> DebtCollectors { get; set; } public virtual ICollection<DesignatedServiceProvider> DesignatedServiceProviders { get; set; } public virtual ICollection<DiagnosisCode> DiagnosisCodes { get; set; } public virtual ICollection<Doctor> Doctors { get; set; } public virtual ICollection<EdiTransmissionBatch> EdiTransmissionBatches { get; set; } public virtual ICollection<EdidestinationConfiguration> EdidestinationConfigurations { get; set; } public virtual ICollection<EraglobalConfiguration> EraglobalConfigurations { get; set; } public virtual ICollection<GlobalTariff> GlobalTariffs { get; set; } public virtual ICollection<Invoice> Invoices { get; set; } public virtual ICollection<Laboratory> Laboratories { get; set; } public virtual ICollection<LogReportView> LogReportViews { get; set; } public virtual ICollection<LogTransactionTreatmentCode> LogTransactionTreatmentCodes { get; set; } public virtual ICollection<Macro> Macros { get; set; } public virtual ICollection<MedicalAidPackagePriceIncrease> MedicalAidPackagePriceIncreases { get; set; } public virtual ICollection<MedicalAidPmbexclusion> MedicalAidPmbexclusions { get; set; } public virtual ICollection<MedicalAidPriceIncreaseContract> MedicalAidPriceIncreaseContracts { get; set; } public virtual ICollection<MedicalAidPriceIncrease> MedicalAidPriceIncreases { get; set; } public virtual ICollection<MedicalAidTreatmentModifierOverride> MedicalAidTreatmentModifierOverrides { get; set; } public virtual ICollection<MedicalCertificate> MedicalCertificates { get; set; } public virtual ICollection<Modifier> Modifiers { get; set; } public virtual ICollection<PatientClinicalNote> PatientClinicalNotes { get; set; } public virtual ICollection<Patient> Patients { get; set; } public virtual ICollection<PracticeMedicalAidContract> PracticeMedicalAidContracts { get; set; } public virtual ICollection<PracticeMedicalAidPlanTypeTreatmentExclusion> PracticeMedicalAidPlanTypeTreatmentExclusions { get; set; } public virtual ICollection<PracticeMedicalAidPriceIncreaseContract> PracticeMedicalAidPriceIncreaseContracts { get; set; } public virtual ICollection<PracticeMedicalAidTreatmentPrice> PracticeMedicalAidTreatmentPrices { get; set; } public virtual ICollection<PracticeMedicalAidWebLogin> PracticeMedicalAidWebLogins { get; set; } public virtual ICollection<PracticeMedicalAid> PracticeMedicalAids { get; set; } public virtual ICollection<PracticeMemoSession> PracticeMemoSessions { get; set; } public virtual ICollection<PracticeMonthEndDateConfiguration> PracticeMonthEndDateConfigurations { get; set; } public virtual ICollection<PracticeMonthEndReport> PracticeMonthEndReports { get; set; } public virtual ICollection<PracticeMonthEndVatHistory> PracticeMonthEndVatHistories { get; set; } public virtual ICollection<PracticeSystemParameter> PracticeSystemParameters { get; set; } public virtual ICollection<Prescription> Prescriptions { get; set; } public virtual ICollection<ProcedureRequest> ProcedureRequests { get; set; } public virtual ICollection<Quotation> Quotations { get; set; } public virtual ICollection<Recall> Recalls { get; set; } public virtual ICollection<ReportParameterValue> ReportParameterValues { get; set; } public virtual ICollection<Script> Scripts { get; set; } public virtual ICollection<SystemParameterValue> SystemParameterValues { get; set; } public virtual ICollection<Task> Tasks { get; set; } public virtual ICollection<Transaction> Transactions { get; set; } public virtual ICollection<TransmissionSummaryLog> TransmissionSummaryLogs { get; set; } public virtual ICollection<TreatmentCode> TreatmentCodes { get; set; } public virtual ICollection<UserLoginHistory> UserLoginHistories { get; set; } public virtual ICollection<Vendor> Vendors { get; set; } public virtual ICollection<Depot> Depots { get; set; } public virtual ICollection<Icd10> Icd10s { get; set; } public virtual ICollection<MedicalAid> MedicalAids { get; set; } public virtual ICollection<MedicineMarkupStructure> MedicineMarkupStructures { get; set; } public virtual ICollection<PlaceOfService> PlaceOfServices { get; set; } public virtual ICollection<PlaceOfTreatment> PlaceOfTreatments { get; set; } public virtual ICollection<PriceIncreaseContract> PriceIncreaseContracts { get; set; } public virtual ICollection<Sms> Sms { get; set; } public virtual ICollection<Term> Terms { get; set; } } }
-
0
Hi,
You can try this:
public partial class Practice : AuditedEntity { //........ public int PracticeId { get; set; } public override object[] GetKeys() { return new object[] { PracticeId }; } }
-
0
Hi,
You can try this:
public partial class Practice : AuditedEntity { //........ public int PracticeId { get; set; } public override object[] GetKeys() { return new object[] { PracticeId }; } }
The problem with this solution is that I cannot use the generic reposo if I inherit from AuditEntity. I still need to use the repos with the entity
-
0
I cannot use the generic reposo if I inherit from AuditEntity
What is the error?
-
0
I cannot use the generic reposo if I inherit from AuditEntity
What is the error?
From What I can see, if I take the type out of the AuditedEntity declaration then it does not allow you to use the generic repos.
I have another class detailed below. MemoId is the primary key for the table, so I do not need the Id property, If I inherit the class from AuditedEntity<Guid> then the migration creates the Id property if I use AuditedEntity like below then the migration does not create the Id column. The problem is that if I enherit from AuditedEntity then I cannot use the generic repo, the application service is giving me an error There is no implicit conversion between AccountMemo and IEntity<System.Guid>
public partial class AccountMemo : AuditedEntity { public AccountMemo() { AccountMemoAttachments = new HashSet<AccountMemoAttachment>(); PracticeMemoSessionAccountMemos = new HashSet<PracticeMemoSessionAccountMemo>(); Transactions = new HashSet<Transaction>(); // AccountMemoTransactions = new HashSet<AccountMemoTransaction>(); }
//[NotMapped] //public override Guid Id //{ // get { return new Guid(); } //} public Guid MemoId { get; set; } public Guid AccountId { get; set; } public int? UserId { get; set; } public int? AccountMemoTypeId { get; set; } public DateTime Date { get; set; } public string Memo { get; set; } public bool IsArchived { get; set; } public virtual Account Account { get; set; } public virtual AccountMemoType AccountMemoType { get; set; } public virtual SecurityUser User { get; set; } public virtual ICollection<AccountMemoAttachment> AccountMemoAttachments { get; set; } public virtual ICollection<PracticeMemoSessionAccountMemo> PracticeMemoSessionAccountMemos { get; set; } //public virtual ICollection<AccountMemoTransaction> AccountMemoTransactions { get; set; } public virtual ICollection<Transaction> Transactions { get; set; } public override object[] GetKeys() { return new object[] { MemoId }; } } public class AccountMemoAppService : CrudAppService< AccountMemo, AccountMemoDto, Guid, PagedAndSortedResultRequestDto, AccountMemoCreateUpdateDto>, IAccountMemoAppService { public AccountMemoAppService(IRepository<AccountMemo, Guid> repository) : base(repository) { }
-
0
Hi,
if I use AuditedEntity like below then the migration does not create the Id column. The problem is that if I enherit from AuditedEntity then I cannot use the generic repo
Hi, you can of course use a generic repository, use
AbstractKeyCrudAppService
instead ofCrudAppService
. check this: https://docs.abp.io/en/abp/5.1/Application-Services#abstractkeycrudappservice