asp.net webapi 给字段赋初始值DefaultValue 解决前端传空字符串后台接受不是“”而是NULL

/// <summary>
        /// 存储ID
        /// </summary> 
        public Guid SaveID { get; set; }
        /// <summary>
        /// 类型ID
        /// </summary>
        [DefaultValue(0)]
        public int DefineID { get; set; }
        /// <summary>
        /// 红线内
        /// </summary>
        [DefaultValue(0.000)]
        public decimal RedInSq { get; set; }
        /// <summary>
        /// 红线外
        /// </summary>
        [DefaultValue(0.000)]
        public decimal RedOutSq { get; set; }
        /// <summary>
        /// 工程项目ID
        /// </summary>
        public Guid ProjectID { get; set; }
        /// <summary>
        /// 计量单位
        /// </summary>
        [DefaultValue("")]
        public string UnitName { get; set; }

 

posted @ 2020-07-14 10:41  netlock  阅读(682)  评论(2编辑  收藏  举报