C#反射赋值(更新时用)

        /// <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);
            }
        }

 

C#反射赋值(更新时用)

上一篇:Delphi 错误提示: Unknown picture file extension (.jpg)


下一篇:P2657 [SCOI2009] windy 数