public static class MapperExtensions { public static TResult MapTo<TResult>(this object self, TResult result) { if (self == null) throw new ArgumentNullException(); Mapper.CreateMap(self.GetType().UnderlyingSystemType, typeof(TResult)); return (TResult)Mapper.Map(self, result, self.GetType(), typeof(TResult)); } }
调用
f.MapTo(Entity);//f源 Entity目标
原文:http://www.cnblogs.com/lee2011/p/5191542.html