【发布时间】:2014-03-06 20:24:33
【问题描述】:
我有 UserType 对象,其中名称属性值是类属性的 UserId、LoginName、Email 等。我需要将 UserType 对象映射到 User 对象并从 User 反向映射到 UserType 。我使用了 AutoMapper 库,但我无法实现映射。
public class UserType
{
public string UserName { get; set; }
public Attribute[] Attribute { get; set; }
}
用户属性类:
public class Attribute
{
public string Name { get; set; }
public string[] Value { get; set; }
}
属性示例:属性attribute = new Attribute { Name = "LoginName", Value = new []{"LoginName"} }
我的用户类:
public class User
{
public long UserId { get; set; }
public string LoginName { get; set; }
public string Email { get; set; }
public string LastName { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
}
【问题讨论】: