У меня проблема при попытке сопоставить следующий класс.
class LazyStudent : ActiveRecordBase
{
[Property]
public String Name
{
set;
get;
}
[HasMany(typeof(LazyStudentBook))]
public IList<LazyStudentBook> Books
{
set;
get;
}
}
class LazyStudentBook : ActiveRecordBase
{
[Property]
public String BookName
{
set;
get;
}
[HasMany(typeof(LazyStudentBookPicture))]
public IList<LazyStudentBookPicture> Pictures
{
set;
get;
}
[BelongsTo]
public LazyStudent LazyStudent
{
set;
get;
}
}
class LazyStudentBookPicture : ActiveRecordBase
{
[Property]
public String PictureName
{
set;
get;
}
[Property]
public LazyStudentBook LazyStudentBook
{
set;
get;
}
}
class Student
{
public String Name
{
set;
get;
}
public IList<StudentBook> Books
{
set;
get;
}
}
class StudentBook
{
public String BookName
{
set;
get;
}
public IList<StudentBookPicture> Pictures
{
set;
get;
}
}
class StudentBookPicture
{
public String PictureName
{
set;
get;
}
}
class TestAutoMapper
{
public static void Start()
{
Mapper.CreateMap<LazyStudent, Student>();
Mapper.CreateMap<LazyStudentBook, StudentBook>();
Mapper.CreateMap<LazyStudentBookPicture, StudentBookPicture>();
Mapper.CreateMap<IList<LazyStudent>, IList<LazyStudent>>();
Mapper.CreateMap<IList<LazyStudentBookPicture>, IList<StudentBookPicture>>();
IList<LazyStudent> lazyStudents = new List<LazyStudent>
{
new LazyStudent{
Name = "AAA",
Books = new List<LazyStudentBook>{
new LazyStudentBook{
BookName = "BookName"
/*,
Pictures = new List<LazyStudentBookPicture>{
new LazyStudentBookPicture{
PictureName = "PictureName"
}, new LazyStudentBookPicture{
PictureName = "PictureName"
}
}*/
}
}
}
};
IList<Student> sList = Mapper.Map<IList<LazyStudent>, IList<Student>>(lazyStudents);
}
}
Над кодом хорошо работает, но когда я раскомментирую "Pictures = new" ... Это исключение
Trying to map System.Collections.Generic.IList`1[[TestAOP.LazyStudent, Test.Com.Ko.Aop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to System.Collections.Generic.IList`1[[TestAOP.Student, Test.Com.Ko.Aop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
Доза, которую можно мне сказать В чем моя ошибка?AutoMapper поддерживает эту классную структуру?
Спасибо.