列字段有特殊字符时,update 失败问题 已开启IsCorrectErrorSqlParameterName = t 返回

SqlSugar 处理完成
8 700
该叫什么 大力 发布于2024/5/15
悬赏:0 飞吻
       SqlSugar.SqlSugarClient DB = new SqlSugarClient(new ConnectionConfig { ConnectionString = "Server=.;UID=aa;PWD=bb;DataBase=test", DbType = SqlSugar.DbType.SqlServer });
       DB.CurrentConnectionConfig.MoreSettings = new ConnMoreSettings() { IsCorrectErrorSqlParameterName = true };
       var ent = new Test1.Tax_Base_EmpSerial { Serial = "202401", 工号 = "1001", 户籍所在地_详细地址 = "湖南长沙" };
      var i = DB.Updateable(ent).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
       //会报错,原因是  DB.Updateable(ent) 时将所有参数添加到Paramers 里时已添加有特殊字段的列,然后在处理ignoreAllNullColumns: true时 该列因为@户籍所在地(省) 为Null  生成update 时该参数报错
using System;
using SqlSugar;

namespace Test1
{
    /// <summary>
    /// Tax_Base_EmpSerial
    /// </summary>
    [Serializable]
    [SugarTable("tax_base_empserial", "Tax_Base_EmpSerial", IsDisabledDelete =true)]
    public partial class Tax_Base_EmpSerial
    {
        /// <summary>
        ///Serial
        /// </summary>
        [SugarColumn(ColumnName = "serial", ColumnDescription = "Serial", IsPrimaryKey = true, Length = 20, IsNullable = false)]
        public string Serial { get; set; }

        /// <summary>
        ///工号
        /// </summary>
        [SugarColumn(ColumnName = "工号", ColumnDescription = "工号", Length = 50, IsNullable = true)]
        public string 工号 { get; set; }

        /// <summary>
        ///户籍所在地(详细地址)
        /// </summary>
        [SugarColumn(ColumnName = "户籍所在地(详细地址)", ColumnDescription = "户籍所在地(详细地址)", Length = 255, IsNullable = true)]
        public string 户籍所在地_详细地址 { get; set; }

        /// <summary>
        ///户籍所在地(详细地址)
        /// </summary>
        [SugarColumn(ColumnName = "户籍所在地(省)", ColumnDescription = "户籍所在地(省)", Length = 255, IsNullable = true)]
        public string 户籍所在地_省 { get; set; }

    }
}


热忱回答8

  • fate sta fate sta VIP0
    2024/5/15

    什么库描述清楚

    0 回复
  • 大力 大力 VIP0
    2024/5/15

    DbType = SqlSugar.DbType.SqlServer 

    SQL Server 

    0 回复
  • 大力 大力 VIP0
    2024/5/15

    image.png

    0 回复
  • fate sta fate sta VIP0
    2024/5/15

    SqlSugarCore 5.1.4.155-preview20


    过五分钟后安装已修复

    0 回复
  • fate sta fate sta VIP0
    2024/5/15

    记得勾一下预览

    0 回复
  • 大力 大力 VIP0
    2024/5/15

    这速度 太快了,可以方便告知改了哪里吗?

    0 回复
  • fate sta fate sta VIP0
    2024/5/15

    nuget 勾一下预览更新

    0 回复
  • 大力 大力 VIP0
    2024/5/15

    大佬 你好,插入也有问题,看能否一并改一下,谢谢

    97736da37e4836f63b32645566682605.png

    0 回复