【发布时间】:2009-02-10 08:40:21
【问题描述】:
假设我有两个类:
public class Student
{
public int Id {get; set;}
public string Name {get; set;}
public IList<Course> Courses{ get; set;}
}
public class StudentDTO
{
public int Id {get; set;}
public string Name {get; set;}
public IList<CourseDTO> Courses{ get; set;}
}
我想将值从 Student 类复制到 StudentDTO 类:
var student = new Student();
StudentDTO studentDTO = student;
如何通过反思或其他解决方案做到这一点?
【问题讨论】:
-
看看Automapper。该工具旨在处理这种确切的情况。
标签: c# .net reflection