MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.31k stars 328 forks source link

Adapt with inherited Class of List<T> loses additional properties #383

Open davide882 opened 2 years ago

davide882 commented 2 years ago

Good morning, I have this code:

public class PagedList<T> : List<T>
{
public int PageNumber{get;set;} 
public int PageSize{get;set;} 
public int TotalCount{get;set;} 
}

public PagedList(Ienumerable<T> collection) : base(Collection) 
{
} 

public class Source
{
public int Val1{get;set;} 
} 

public class Dest
{
public int Val1{get;set;} 
} 

If I do:

var lFrom = new PagedList<Source>{new Source{Val1=6} } ;
lFrom.PageNumber=5;
lFrom.PageSize=10;
lFrom.TotalCount=1;

var lTo = lFrom.Adapt<PagedList<Dest>>();

lTo contains source items but properties PageNumber, PageSize and TotalCount are equal to 0 and not valorized.

davide882 commented 2 years ago

Nobody?