Skip to content
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

Map ExtraProperties of an entity to regular properties of a type-safe dto #7666

Merged

Conversation

iyilm4z
Copy link
Contributor

@iyilm4z iyilm4z commented Feb 9, 2021

Resolves #3128

@maliming maliming self-requested a review February 9, 2021 06:23
@maliming maliming added this to the 4.3-preview milestone Feb 9, 2021
@hikalkan hikalkan self-requested a review February 26, 2021 12:12

foreach (var property in properties)
{
property.SetValue(source, source.ExtraProperties[property.Name]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this property from source.ExtraProperties. No need to duplication. If we define a regular property, we want to use it instead of extra property.
Duplication is dangerous here. Because if we change one of them, the other one won't change.

@hikalkan
Copy link
Member

hikalkan commented Mar 16, 2021

Actually, we may do vice verse too. Map regular properties to extra properties. But, this time we should only copy the extra properties defined for the target class.

I mean we define automapper config for ProductDto->Product mapping with extra properties, we can copy ProductDto.Price to Product.ExtraProperties["Price"] if we've defined the "Price" as an extra property for the Product (using the ObjectExtensionManager).

We can reuse the same mapToRegularProperties, no need to define an additional option.

Note: We can consider this as another issue/PR. Please make my change request and I merge this first ;) Thanks.

@iyilm4z iyilm4z requested a review from hikalkan March 16, 2021 09:23
@hikalkan hikalkan merged commit 1b31b11 into abpframework:dev Mar 16, 2021
@hikalkan
Copy link
Member

Thanks!

@iyilm4z iyilm4z deleted the MapExtraPropertiesToRegularProperties branch March 16, 2021 10:28
@michaelsudnik
Copy link

Will this support any form of conversion?

For example we are using MongoDB and have extended the OrganizationUnit entity to include a collection which is loaded as a collection of bson values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to map ExtraProperties of an entity to a type-safe DTO?
4 participants