Hi there,
I am using ASP.NETCORE and Augular.
If I want to add a new ReadOnly calculated field (TotalField) to a Dto that has been generated using the Swagger refresh.bat in the service-proxies.ts, what is the best way to do this?
- Goal is that when the user enters a value into FieldOne and/or FieldTwo on the UI, a TotalField shows the calculation result as a label
- i.e: TotalField = (FieldOne x FieldTwo)
Any thoughts on the right approach?
Regards John
3 Answer(s)
-
0
as far as know. nswag just can generate DTO in client. you need achieve it in client by your self.
Use angular template-syntax to calculate it automatically and submit it to the backend. Of course, you can verify it again if you need the backend.
-
0
What about this in entity class:
[NotMapped] public int TotalField { get { return FieldOne * FieldTwo; } }
now you can have a DTO as usual:
public int TotalField { get; set; }
-
0
you can skip mapping for
TotalField
in auto mapper entity-dto or dto-entity configuration.see https://github.com/aspnetzero/aspnet-zero-core/blob/4180b6eccb0c02e14a17d1e383ed3906f6174cdd/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application/CustomDtoMapper.cs#L109