我是 C# 的新手,dotnet 核心。我正在从数据库中获取数据,如下所示。这个数据很平淡。我需要转换为另一个对象。
public class Lead
{
public long Id { get; set; }
public short LeadCreatorId { get; set; }
public short LeadOwnerId { get; set; }
public string ProductId { get; set; }
public LeadPriority Priority { get; set; }
public LeadStatus Status { get; set; }
public long LeadCustomerId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string MobileNo { get; set; }
public DateTime CreatedOn { get; set; }
}
我需要将其转换为以下对象。
public class LeadDto
{
public long Id { get; set; }
public short LeadCreatorId { get; set; }
public short LeadOwnerId { get; set; }
public string ProductId { get; set; }
public LeadPriority Priority { get; set; }
public LeadStatus Status { get; set; }
public LeadCustomer LeadCustomer { get; set; }
public DateTime CreatedOn { get; set; }
}
LeadCustomer 如下所示 -
public class LeadCustomer{
public long Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string MobileNo { get; set; }
}
我怎样才能轻松做到这一点?我可以使用 dto 进行转换吗?
慕婉清6462132
白板的微信
跃然一笑
幕布斯7119047
相关分类