/// <summary> /// 私有辅助方法 /// </summary> /// <param name="db"></param> /// <param name="entity"></param> private void UpdateHelper(T db, T entity) { foreach (var prop in typeof(T).GetProperties()) { object value = entity.GetType().GetProperty(prop.Name).GetValue(entity, null); typeof(T).GetProperty(prop.Name).SetValue(db, value); } }