插入doris数据库报错 返回

SqlSugar 沟通中
3 299

函数:

private static void InAlarmDb (string DbName, List<Alarm_Min> Alarm_Min_List) 

{ try

 { using var db = Doris.GetSc (DbName); 

 db.Ado.CommandTimeOut = 10 * 48 * 3600; 

  int Rows = db.Insertable (Alarm_Min_List).ExecuteCommand (); 

Lg.Info($"向数据表:Alarm_Min 插入数据条数:{Rows}"); } 

catch (Exception ex) 

{ Lg.Error (ex.Message); } }


插入doris数据库报错:2026-08-10 11:00:24.117 [ERR] CliDo|InAlarmDb errCode = 2, detailMessage = Unknown system variable 'IDENTITY'


Doris 不支持 MySQL 的 IDENTITY 自增语法。


实体:

  [SugarTable("Alarm_Min")]  
  public class Alarm_Min
  { 
      public DateTime DateId { get; set; }      public string HourId { get; set; }      public string MinId { get; set; }      public string CityName { get; set; }      public string NodeId { get; set; }      public string PresentSeverity { get; set; }      public string SpecificProblem { get; set; }      public string EventTime { get; set; }      public string ObjectOfReference { get; set; }      public string ProblemText { get; set; }      public string AlarmState { get; set; }      public string AlarmId { get; set; }      public string ProbableCause { get; set; }      public string EventType { get; set; }      public string RecordType { get; set; }

  }


热忱回答(3)

  • codefish codefish VIP0
    1个月前

    插入脚本中,有select @@IDENTITY,是否可以去掉?怎么去掉?

    0 回复
  • codefish codefish VIP0
    1个月前

      int Rows = db.Insertable (Alarm_Min_List).ExecuteCommand ();  ----这条插入产生的SQL中,最后包括select @@IDENTITY,是否可以去掉?怎么去掉?


    0 回复
  • fate sta fate sta VIP0
    1个月前

    sqlsugar 是最新吗,老的可以用AOP去掉。

    0 回复