1

有两种类型继承List,我想用AutoMapper映射它。映射类型继承自 List 时映射结果为空

class Program
{
    static void Main(string[] args)
    {
        Mapper.Initialize(cfg =>
        {
            cfg.CreateMap(typeof(ListA<>), typeof(ListB<>));
        });

        ListA<string> a = new ListA<string>()
        {
            Name = "A"
        };
        a.Add("AAAA");


        var b = Mapper.Map<ListB<string>>(a);

        Console.ReadKey();
    }
}


class ListA<T> : List<T>
{
    public string Name { get; set; }
}
class ListB<T> : List<T>
{
    public string Name { get; set; }
}
4

0 回答 0