C
C#2mo ago
kasen0177

Help needed with design design

So i am creating an audit log dashboard I will have a dropdown of tables, user select one and I fetch the audit logs for that table. I have a quite a of tables to fetch I am using the Clean Architecture. I was thinking of having function called GetLogByTable(string tableName) but then I have like 7 entities and I would have to map to dto dynamically which confuses me. Is there a better approach?
8 Replies
sibber
sibber2mo ago
why does that confuse you?
kasen0177
kasen01772mo ago
cuz if i want one function and i have 7 entities how do i dynamically map it to 7 dtos using automapper or maybe im just tryna push something thats wrong too far
Pobiega
Pobiega2mo ago
You would use a base class or interface, and polymorphism. Automapper supports this just fine
blueberriesiftheywerecats
You can also try Mapster, it automatically mappes your data without need of creating profiles
Angius
Angius2mo ago
Or Riok.Mapperly that uses source generators, so you don't need to rely on reflections
kasen0177
kasen01772mo ago
hey guys yeah i created a base entity and a base dto currently i am mapping it with .Map<respectivedtos>(theentity) but i have to use like a big switch statement
kasen0177
kasen01772mo ago
No description
kasen0177
kasen01772mo ago
there is documentaton on how to map it without explicitly naming the destination dto but doesnt seem to work with IEnumerable<>
Want results from more Discord servers?
Add your server