2
我有以下類:AutoMapper問題 - 列表不會地圖
public class Account
{
public int AccountID { get; set; }
public Enterprise Enterprise { get; set; }
public List<User> UserList { get; set; }
}
和我有以下方法段:
Entities.Account accountDto = new Entities.Account();
DAL.Entities.Account account;
Mapper.CreateMap<DAL.Entities.Account, Entities.Account>();
Mapper.CreateMap<DAL.Entities.User, Entities.User>();
account = DAL.Account.GetByPrimaryKey(this.Database, primaryKey, withChildren);
Mapper.Map(account,accountDto);
return accountDto;
當方法被調用時,賬戶類被映射正確,但Account類中的用戶列表不(它是NULL)。 List中有四個用戶實體應該被映射。有人能告訴我什麼可能是錯的嗎?