4 ms·
I assume the automapper is subsetting on the target type's structure, right? So its something like this, target_dto = { k: MyDbModel.get(k) for k in MyTar
by mjburgess 4y ago
I assume the automapper is subsetting on the target type's structure, right?
So its something like this,
target_dto = { k: MyDbModel.get(k) for k in MyTargetModel.keys() }
Writing this is a big issue with simple static languages (ie., those without much compile-time programming).
This deficiency should really be addressed at the language-level. Ie., what you want is structural typing in the view-layer, and a means of restructuring (ie., filtering) the original db object.
So,
renderView(myDbModel as {Just,The,Necessary,Fields})
I'd imagine with C# Shapes, Extension Methods and Pattern Matching, you'd be able to do roughly this -- but i'm not sure of the status of "shapes" (ie., typeclasses) in the C# RFC process.
- orra 4y agoThanks for this thoughtout reply. Automapping can also be used for renaming, and simple type conversions. But yes, structural typing and other interesting typesystems can make this first class. I didn't realise serious work had been put into typeclasses for C#. Interesting, but unfortunately it seems to have stalled.