mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-10 11:25:00 +08:00
-
This commit is contained in:
@@ -28,6 +28,7 @@ namespace SqlSugar
|
|||||||
public bool IsNoInsertNull { get; set; }
|
public bool IsNoInsertNull { get; set; }
|
||||||
public bool IsReturnIdentity { get; set; }
|
public bool IsReturnIdentity { get; set; }
|
||||||
public EntityInfo EntityInfo { get; set; }
|
public EntityInfo EntityInfo { get; set; }
|
||||||
|
public Dictionary<string, int> OracleSeqInfoList { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SqlTemplate
|
#region SqlTemplate
|
||||||
|
|||||||
@@ -11,8 +11,24 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return this.EntityInfo.Columns.Where(it => it.OracleSequenceName.IsValuable()).Select(it => it.DbColumnName).ToList();
|
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