Browse Source

Update SqlServer Insert

SqlSugar5
sunkaixuan 2 years ago
parent
commit
78efee8ebd
  1. 1
      Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs
  3. 5
      Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerInsertBuilder.cs

1
Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs

@ -109,6 +109,7 @@ namespace SqlSugar
else if (isIdEntity && this.InsertBuilder.ConvertInsertReturnIdFunc != null)
{
string sql = _ExecuteCommand();
InsertBuilder.IsNoPage = true;
sql = this.InsertBuilder.ConvertInsertReturnIdFunc(SqlBuilder.GetTranslationColumnName(pkInfo.DbColumnName),sql);
var result = Ado.SqlQuery<Type>(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
After(sql, null);

1
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -122,6 +122,7 @@ namespace SqlSugar
}
public virtual Func<string,string,string> ConvertInsertReturnIdFunc { get; set; }
public virtual bool IsNoPage { get; set; }
public virtual ExpressionResult GetExpressionValue(Expression expression, ResolveExpressType resolveType)
{

5
Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlBuilder/SqlServerInsertBuilder.cs

@ -12,6 +12,7 @@ namespace SqlSugar
{
return sql.Replace("select SCOPE_IDENTITY();", "").Replace(")\r\n SELECT", $")\r\n OUTPUT INSERTED.{name} as {name} \r\nSELECT");
};
public override bool IsNoPage { get; set; } = true;
public override string ToSqlString()
{
if (IsNoInsertNull)
@ -38,6 +39,10 @@ namespace SqlSugar
{
pageSize = 100;
}
if (IsNoPage)
{
pageSize = groupList.Count;
}
int pageIndex = 1;
int totalRecord = groupList.Count;
int pageCount = (totalRecord + pageSize - 1) / pageSize;

Loading…
Cancel
Save