public static void MergeWith(this T primary, T secondary) { foreach (var pi in typeof(T).GetProperties()) { var priValue = pi.GetGetMethod().Invoke(primary, null); var secValue = pi.GetGetMethod().Invoke(secondary, null); bool bnullable = false; if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition() == typeof(Nullable<>)) bnullable = true; if (((bnullable && secValue != null) == false) && !priValue.Equals(secValue)) { pi.GetSetMethod().Invoke(primary, new object[] { secValue }); } } }