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
why does that confuse you?
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
You would use a base class or interface, and polymorphism. Automapper supports this just fine
You can also try Mapster, it automatically mappes your data without need of creating profiles
Or
Riok.Mapperly
that uses source generators, so you don't need to rely on reflectionshey 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
![No description](https://cdn.answeroverflow.com/1265778917533286614/Screenshot_2024-07-24_at_5.13.24_PM.png)
there is documentaton on how to map it without explicitly naming the destination dto
but doesnt seem to work with IEnumerable<>