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

ShallowCopyForSameType(true) not working with Mapster.Tool #668

Open
ichalyshev opened this issue Dec 8, 2023 · 1 comment
Open

ShallowCopyForSameType(true) not working with Mapster.Tool #668

ichalyshev opened this issue Dec 8, 2023 · 1 comment

Comments

@ichalyshev
Copy link

I have type hierarchy

public class ProvinceInfo
{
	public string Code { get; set; }
	public string Title { get; set; }
}

class Address
{
	public ProvinceInfo Province { get; set; } 
}

class AddressState
{
	public ProvinceInfo Province { get; set; } 
}

and mapster config

...
config
	.NewConfig<ProvinceInfo, ProvinceInfo>()
	.ShallowCopyForSameType(true);

config
	.NewConfig<AddressState, Address>()
	.ShallowCopyForSameType(true)
...

when i generate mappers with Mapster.Tool i consistantly receive deep copy:

public AddressState MapTo(Address p1)
...
Province = new ProvinceInfo()
{
	Code = p1.Province.Code,
	Title = p1.Province.Title
},
...

i neen copy by reference here, but can't achive it.

By the way, please suggest mapster learning materials. Official docs seems useless.

@ichalyshev
Copy link
Author

my fault

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

No branches or pull requests

1 participant