Update pgsql return pklist

This commit is contained in:
sunkaixuan 2022-08-24 01:06:09 +08:00
parent c73bc9ce81
commit aae91c90a0
2 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,14 @@ namespace OrmTest
var ids2 = db.Insertable(new List<UnitIdentity01>() { new UnitIdentity01() { Name = "c" }, new UnitIdentity01() { Name = "c" } }).ExecuteReturnPkList<int>(); var ids2 = db.Insertable(new List<UnitIdentity01>() { new UnitIdentity01() { Name = "c" }, new UnitIdentity01() { Name = "c" } }).ExecuteReturnPkList<int>();
if (ids2.Count(z => z > 0) != 2) { throw new Exception("unit error"); } if (ids2.Count(z => z > 0) != 2) { throw new Exception("unit error"); }
if (db.Queryable<UnitIdentity01>().In(ids2).Count() != 2) { throw new Exception("unit error"); } if (db.Queryable<UnitIdentity01>().In(ids2).Count() != 2) { throw new Exception("unit error"); }
var list = new List<UnitIdentity01>();
for (int i = 0; i < 1000; i++)
{
list.Add(new UnitIdentity01() { Name = "a" });
}
var ids3 = db.Insertable(list).ExecuteReturnPkList<int>();
if (db.Queryable<UnitIdentity01>().In(ids3).Count() != 1000) { throw new Exception("unit error"); }
db.DbMaintenance.TruncateTable<UnitIdentity01>();
} }
public class UnitGuid123 public class UnitGuid123

View File

@ -56,6 +56,10 @@ namespace SqlSugar
StringBuilder batchInsetrSql = new StringBuilder(); StringBuilder batchInsetrSql = new StringBuilder();
int pageSize = 200; int pageSize = 200;
int pageIndex = 1; int pageIndex = 1;
if (IsNoPage&&IsReturnPkList)
{
pageSize = groupList.Count;
}
int totalRecord = groupList.Count; int totalRecord = groupList.Count;
int pageCount = (totalRecord + pageSize - 1) / pageSize; int pageCount = (totalRecord + pageSize - 1) / pageSize;
while (pageCount >= pageIndex) while (pageCount >= pageIndex)