如何从一个 实体 复制到 另一个相同结构的实体
两个实体 他们的属性、结构一样 我怎么把一个实体的值复制到另一个实体 不要一一赋值
------解决方案--------------------google “c# 深拷贝,浅拷贝”
------解决方案--------------------http://bbs.csdn.net/topics/390600500?page=1#post-395653832
------解决方案--------------------也可以使用序列化和反序列化
------解决方案--------------------可以使用AutoMapper 库
AutoMapper is a simple little library built to solve a deceptively complex problem - getting rid of code that mapped one object to another. This type of code is rather dreary and boring to write, so why not invent a tool to do it for us?
https://github.com/AutoMapper/AutoMapper
------解决方案--------------------public T Clone<T>(T RealObject)
{
using (Stream objectStream = new MemoryStream())
{
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(objectStream, RealObject);
objectStream.Seek(0, SeekOrigin.Begin);
return (T)formatter.Deserialize(objectStream);
}
}