You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.7 KiB

using DocumentFormat.OpenXml.Drawing.Charts;
using medical.transfomer.entity;
using ReZero.DependencyInjection;
using ReZero.SuperAPI;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace medical.transfomer.business
{
public class std_object_mapping_business : IScopeContract
{
public ISqlSugarClient? db = ZeroDb.Db;
public Task<object> ExecuteAction(DataModel dataModel)
{
throw new NotImplementedException();
}
// 批量插入信息
public int ListInsert(List<STD_OBJECT_MAPPING> list)
{
try
{
db!.Ado.BeginTran();
// 完全避免批量插入语法,改用循环逐条插入
int result = 0;
foreach (var item in list)
{
// 不要设置ID为null,而是完全忽略ID列
result += db!.Insertable(item)
.IgnoreColumns(it => new { it.ID }) // 完全忽略ID列,让Oracle生成
.ExecuteCommand();
}
db!.Ado.CommitTran();
return result;
}
catch (Exception ex)
{
db!.Ado.RollbackTran();
// 记录错误详情以便调试
Console.WriteLine($"Oracle插入错误: {ex.Message}");
if (ex.InnerException != null)
Console.WriteLine($"内部错误: {ex.InnerException.Message}");
throw;
}
}
}
}