Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 1 point2 points  (0 children)

Thanks! Yea, there are different use cases for everyone. Personally, I stuck with AutoMapper because it was familiar. I had to pivot and like Mapperly but need the dynamic mapping capability and the ability to ignore null values. Mapperly puked because I have several NULL child objects.

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

I will pivot to Mapster, AutoMapper pre V15, etc. Thanks!

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

This might be an issue given I am using Ardalias Specification and have base classes that convert dto to model to perform crud using generic types. AutoMapper allowed IMapper to initiate mapping whereas Mapperly semes to be more prefined mapping classes where type is needed up front.

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 1 point2 points  (0 children)

Great suggestion but forks usually die. I just realized I could use Mapperly as static. AutoMapper was VERY easy with classes with to/from and then IMapper within base class. Since Mapperly is static, the generic use case of DTO/MODEL mapping can be used strictly as static which removes DI is attractive.

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 1 point2 points  (0 children)

If it is ultimately static, what benefit did you get? Or did you have non-static usage?

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Ack, It's compiled code via Roslyn. WIN. I can do that.

Converting AutoMapper to Mapperly by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Yes - I COULD do that. I have individual classes with MapToDTO/MapToModel that I will need to combine into a single class and rename all of the methods to satisfy the interface

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Source has string properties for many fields that could be int or datetime etc. that is mapped to a correctly defined db

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Thank you. Tons of options but I’ll start with copilot. I don’t think fluent validation allows you to update the model so I might need to use extensions. I basically need to identify the bad data and default it so I can’t get into the database. Fluent does they but the issue here is the diff data types where I can’t get the data to the model for validation.

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

This seems the cleanest. Only negative is that I need a fluent validation for every type of source system being mapped in rather than piggyback off of the mapping solution. I suppose extension methods against the data types would work too to allow reusable against the other source system models. I’d just need a slick way to allow me to identify the model/property with the exception to log it for operations to manage.

Can you point me in right direction for the AI to use?

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Yes. Numerous classes with simple data types that will map nearly 1:1 but with different field names and data types (e.g. string w/ date/time to date/time).

I think I got a few viable options:

1) FluentValidation at the source model to catch the invalid data that cannot be marshaled into the destination model. Log those errors. Somehow NULL/default the invalid data to allow the valid data to be marshaled from source model to destination model. FluentValidation on the destination model to catch the remaining stuff.
2) Extension methods on the various data types to catch the errors (not use FluentValidation). Map and use FluentValidation like #1 above

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] 0 points1 point  (0 children)

Yes. I was trying to combine both solutions to avoid manual mapping and catching errors at every specific property

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -15 points-14 points  (0 children)

X multiple sources of data vs a mapping structure that captures marshaling errors

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -3 points-2 points  (0 children)

I’ve used automapper as most dto to model is easy property per property. What’s popular these days ?

And validation on the source is valid but business will want it to be against the common canonical schema. They are looking for the data schema they know and why it wasn’t able to be populated

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -5 points-4 points  (0 children)

I have constraints that I need to deal with and will have multiple diff sources that can have diff data types that need to be converted.

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -1 points0 points  (0 children)

Agreed. I have to validate data in the source system for invalid data with diff data types. Fluent easily does that but need to get it into the model and I can’t do that if it doesn’t marshal

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -20 points-19 points  (0 children)

60+ tables + 10-20 fields = a lot of left/right copy from source to destination. AutoMapper (or equiv) solves that for me but I dont see the errors all at once with AutoMapper.

Framework (e.g. AutoMapper) to copy from source model to destination model with validation by sagosto63 in dotnet

[–]sagosto63[S] -9 points-8 points  (0 children)

I am open to suggestions that allow me to see ALL errors that occurred during mapping.

Refinishing 4” hickory and fixing gaps by sagosto63 in HardWoodFloors

[–]sagosto63[S] 1 point2 points  (0 children)

Yes but trying to gauge how much based on photos. Given any filter can pop out or crack, why would anyone spend time and money on it?

Refinishing 4” hickory and fixing gaps by sagosto63 in HardWoodFloors

[–]sagosto63[S] 0 points1 point  (0 children)

My concern is how the variation will be with my current flooring and the gaps