mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-09 02:44:58 +08:00
-
This commit is contained in:
@@ -28,6 +28,7 @@ namespace SqlSugar
|
||||
public bool IsNoInsertNull { get; set; }
|
||||
public bool IsReturnIdentity { get; set; }
|
||||
public EntityInfo EntityInfo { get; set; }
|
||||
public Dictionary<string, int> OracleSeqInfoList { get; set; }
|
||||
#endregion
|
||||
|
||||
#region SqlTemplate
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SqlSugar
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class OracleInsertable<T> : InsertableProvider<T> where T : class, new()
|
||||
{
|
||||
@@ -11,8 +11,24 @@ namespace SqlSugar
|
||||
{
|
||||
return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.IsValuable()).Select(it => it.DbColumnName).ToList();
|
||||
}
|
||||
protected override void PreToSql() {
|
||||
|
||||
protected override void PreToSql()
|
||||
{
|
||||
var identities = GetIdentityKeys();
|
||||
var insertCount = InsertObjs.Count();
|
||||
InsertBuilder.OracleSeqInfoList = new Dictionary<string, int>();
|
||||
if (identities.IsValuable()&& insertCount > 1)
|
||||
{
|
||||
Check.Exception(identities.Count != identities.Distinct().Count(), "The field sequence needs to be unique");
|
||||
foreach (var seqName in identities)
|
||||
{
|
||||
int seqBeginValue = 0;
|
||||
this.Ado.ExecuteCommand("alter sequence " + seqName + " increment by " + insertCount);
|
||||
seqBeginValue = this.Ado.GetInt("select " + seqName + ".Nextval from dual") - insertCount;
|
||||
this.Ado.ExecuteCommand("alter sequence " + seqName + " increment by " + 1);
|
||||
InsertBuilder.OracleSeqInfoList.Add(seqName,seqBeginValue);
|
||||
}
|
||||
}
|
||||
base.PreToSql();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user