mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-01-21 10:32:07 +08:00
Bug : ExecuteReturnPkListAsync
This commit is contained in:
@@ -12,31 +12,7 @@ namespace OrmTest
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Demo
|
NewUnitTest.Init();
|
||||||
Demo0_SqlSugarClient.Init();
|
|
||||||
Demo1_Queryable.Init();
|
|
||||||
Demo2_Updateable.Init();
|
|
||||||
Demo3_Insertable.Init();
|
|
||||||
Demo4_Deleteable.Init();
|
|
||||||
Demo5_SqlQueryable.Init();
|
|
||||||
DemoN_SplitTable.Init();
|
|
||||||
Demo6_Queue.Init();
|
|
||||||
Demo7_Ado.Init();
|
|
||||||
Demo8_Saveable.Init();
|
|
||||||
Demo9_EntityMain.Init();
|
|
||||||
DemoA_DbMain.Init();
|
|
||||||
DemoB_Aop.Init();
|
|
||||||
DemoC_GobalFilter.Init();
|
|
||||||
//DemoD_DbFirst.Init();;
|
|
||||||
DemoE_CodeFirst.Init();
|
|
||||||
DemoF_Utilities.Init();
|
|
||||||
DemoG_SimpleClient.Init();
|
|
||||||
DemoH_Tenant.Init();
|
|
||||||
DemoJ_Report.Init();
|
|
||||||
DemoL_Snowflake.Init();
|
|
||||||
DemoM_UnitOfWork.Init();
|
|
||||||
//Unit test
|
|
||||||
//NewUnitTest.Init();
|
|
||||||
|
|
||||||
//Rest Data
|
//Rest Data
|
||||||
NewUnitTest.RestData();
|
NewUnitTest.RestData();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar;
|
||||||
namespace OrmTest
|
namespace OrmTest
|
||||||
{
|
{
|
||||||
public partial class NewUnitTest
|
public partial class NewUnitTest
|
||||||
@@ -34,6 +34,54 @@ namespace OrmTest
|
|||||||
throw new Exception("unit error");
|
throw new Exception("unit error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var list2=db.Insertable(new List<Order22>() {
|
||||||
|
new Order22()
|
||||||
|
{
|
||||||
|
Name = "a",
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CustomId = 1,
|
||||||
|
Price = 1
|
||||||
|
},new Order22()
|
||||||
|
{
|
||||||
|
Name = "a",
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CustomId = 1,
|
||||||
|
Price = 1
|
||||||
|
}
|
||||||
|
}).AS("Order").ExecuteReturnPkList<long>();
|
||||||
|
|
||||||
|
var list3 = db.Insertable(new List<Order>() {
|
||||||
|
new Order ()
|
||||||
|
{
|
||||||
|
Name = "a",
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CustomId = 1,
|
||||||
|
Price = 1
|
||||||
|
},new Order()
|
||||||
|
{
|
||||||
|
Name = "a",
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
CustomId = 1,
|
||||||
|
Price = 1
|
||||||
|
}
|
||||||
|
}).AS("Order").ExecuteReturnPkList<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Order22
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 姓名
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public int CustomId { get; set; }
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public List<OrderItem> Items { get; set; }
|
||||||
}
|
}
|
||||||
public class Unitsdafa111
|
public class Unitsdafa111
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,18 +70,17 @@ namespace SqlSugar
|
|||||||
RestoreMapping();
|
RestoreMapping();
|
||||||
return new KeyValuePair<string, List<SugarParameter>>(sql, InsertBuilder.Parameters);
|
return new KeyValuePair<string, List<SugarParameter>>(sql, InsertBuilder.Parameters);
|
||||||
}
|
}
|
||||||
|
public async Task<List<Type>> ExecuteReturnPkListAsync<Type>()
|
||||||
|
{
|
||||||
|
return await Task.Run(() => ExecuteReturnPkList<Type>());
|
||||||
|
}
|
||||||
public virtual List<Type> ExecuteReturnPkList<Type>()
|
public virtual List<Type> ExecuteReturnPkList<Type>()
|
||||||
{
|
{
|
||||||
var pkInfo= this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey == true);
|
var pkInfo= this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey == true);
|
||||||
Check.ExceptionEasy(pkInfo==null,"ExecuteReturnPkList need primary key", "ExecuteReturnPkList需要主键");
|
Check.ExceptionEasy(pkInfo==null,"ExecuteReturnPkList need primary key", "ExecuteReturnPkList需要主键");
|
||||||
Check.ExceptionEasy(this.EntityInfo.Columns.Count(it => it.IsPrimarykey == true)>1, "ExecuteReturnPkList ,Only support technology single primary key", "ExecuteReturnPkList只支技单主键");
|
Check.ExceptionEasy(this.EntityInfo.Columns.Count(it => it.IsPrimarykey == true)>1, "ExecuteReturnPkList ,Only support technology single primary key", "ExecuteReturnPkList只支技单主键");
|
||||||
var isIdEntity = pkInfo.IsIdentity|| (pkInfo.OracleSequenceName.HasValue()&&this.Context.CurrentConnectionConfig.DbType==DbType.Oracle);
|
var isIdEntity = pkInfo.IsIdentity|| (pkInfo.OracleSequenceName.HasValue()&&this.Context.CurrentConnectionConfig.DbType==DbType.Oracle);
|
||||||
if (pkInfo.UnderType == UtilConstants.LongType)
|
if (isIdEntity&&this.InsertObjs.Length==1)
|
||||||
{
|
|
||||||
return InsertPkListLong<Type>();
|
|
||||||
}
|
|
||||||
else if (isIdEntity&&this.InsertObjs.Length==1)
|
|
||||||
{
|
{
|
||||||
return InsertPkListIdentityCount1<Type>(pkInfo);
|
return InsertPkListIdentityCount1<Type>(pkInfo);
|
||||||
}
|
}
|
||||||
@@ -93,6 +92,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return InsertPkListWithFunc<Type>(pkInfo);
|
return InsertPkListWithFunc<Type>(pkInfo);
|
||||||
}
|
}
|
||||||
|
else if (pkInfo.UnderType == UtilConstants.LongType)
|
||||||
|
{
|
||||||
|
return InsertPkListLong<Type>();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return InsertPkListGuid<Type>(pkInfo);
|
return InsertPkListGuid<Type>(pkInfo);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace SqlSugar
|
|||||||
int ExecuteCommand();
|
int ExecuteCommand();
|
||||||
Task<int> ExecuteCommandAsync();
|
Task<int> ExecuteCommandAsync();
|
||||||
List<Type> ExecuteReturnPkList<Type>();
|
List<Type> ExecuteReturnPkList<Type>();
|
||||||
|
Task<List<Type>> ExecuteReturnPkListAsync<Type>();
|
||||||
long ExecuteReturnSnowflakeId();
|
long ExecuteReturnSnowflakeId();
|
||||||
List<long> ExecuteReturnSnowflakeIdList();
|
List<long> ExecuteReturnSnowflakeIdList();
|
||||||
Task<long> ExecuteReturnSnowflakeIdAsync();
|
Task<long> ExecuteReturnSnowflakeIdAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user