-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapster returning null for Collections instead of empty collection #227
Comments
You can use TypeAdapterConfig.GlobalSettings.Default
.AddDestinationTransform((IReadOnlyList<ChildDto> list) => list ?? new List<ChildDto>()); Problem is you need to list all target types to handle null. I think Mapster need to support this in future version. |
Added generic support for config.Default.AddDestinationTransform(DestinationTransform.EmptyCollectionIfNull); |
Thank you very much. This is great |
@chaowlert This is working great when Collections are a property of a class however when we map Collections directly its still returning null
Here I have tried using both |
I recently migrated to Mapster from Automapper.
We have a huge application and applied mapster and it looks good.
But we are facing an issue that When collections are mapped they are returning as null instead of empty collection when source object property is null.
Is there any workaround or feature so that we can have Empty collection instead of null just like Automapper.
Thanks
The text was updated successfully, but these errors were encountered: