Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

ShallowCopyForSameType(true) not working with Mapster.Tool

Open ichalyshev opened this issue 2 years ago • 1 comments

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 avatar Dec 08 '23 04:12 ichalyshev

my fault

ichalyshev avatar Dec 08 '23 04:12 ichalyshev