c# Mapping Class
public static class TypeExtensions { public static void MapTo<T, S>(this S source, T target) { Type sourceType = source.GetType(); Type targetType = target.GetType(); var sourceProperties = sourceType.GetProperties(); var targetProperties = targetType.GetProperties(); for (int i = 0; i < sourceProperties.Length; i++) { var currentProperty = sourceProperties[i]; var targetProperty = targetProperties .FirstOrDefault(p => p.Name == currentProperty.Name); if (targetProperty != null) targetProperty.SetValue(target, currentProperty.GetValue(source, null), null); } } }