mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update Oracle
This commit is contained in:
parent
daa1a8fc12
commit
87d4077718
@ -49,7 +49,56 @@ namespace OrmTest
|
||||
|
||||
//Use Lock
|
||||
db.Insertable(insertObj).With(SqlWith.UpdLock).ExecuteCommand();
|
||||
Console.WriteLine("SubInsert Start");
|
||||
|
||||
db.Insertable(new Order()
|
||||
{
|
||||
Name = "订单 1",
|
||||
CustomId = 1,
|
||||
Price = 100,
|
||||
CreateTime = DateTime.Now,
|
||||
Id = 0,
|
||||
Items = new List<OrderItem>() {
|
||||
new OrderItem(){
|
||||
CreateTime=DateTime.Now,
|
||||
OrderId=0,
|
||||
Price=1,
|
||||
ItemId=1
|
||||
}
|
||||
}
|
||||
})
|
||||
.AddSubList(it => it.Items.First().OrderId).ExecuteReturnPrimaryKey();
|
||||
db.CodeFirst.InitTables<SubInsertTest, SubInsertTestItem, SubInsertTestItem1, SubInsertTestItem2>();
|
||||
Console.WriteLine("SubInsert Start2");
|
||||
db.Insertable(new List<SubInsertTest>() {
|
||||
new SubInsertTest()
|
||||
{
|
||||
Name="aa",
|
||||
SubInsertTestItem1=new SubInsertTestItem1() {
|
||||
a="nn"
|
||||
},
|
||||
SubInsertTestItem=new SubInsertTestItem()
|
||||
{
|
||||
Name ="item" ,
|
||||
TestId=2
|
||||
}
|
||||
},
|
||||
new SubInsertTest()
|
||||
{
|
||||
Name="aa",
|
||||
SubInsertTestItem1=new SubInsertTestItem1() {
|
||||
a="nn"
|
||||
},
|
||||
SubInsertTestItem=new SubInsertTestItem()
|
||||
{
|
||||
Name ="item" ,
|
||||
TestId=2
|
||||
}
|
||||
}
|
||||
})
|
||||
.AddSubList(it => it.SubInsertTestItem.TestId)
|
||||
.AddSubList(it => it.SubInsertTestItem1)
|
||||
.ExecuteReturnPrimaryKey();
|
||||
Console.WriteLine("#### Insertable End ####");
|
||||
}
|
||||
}
|
||||
|
39
Src/Asp.Net/OracleTest/Models/SubInsertTest.cs
Normal file
39
Src/Asp.Net/OracleTest/Models/SubInsertTest.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class SubInsertTest
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey =true,OracleSequenceName ="Seq_id")]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SqlSugar.SugarColumn(IsIgnore =true)]
|
||||
public SubInsertTestItem SubInsertTestItem { get; set; }
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
public SubInsertTestItem1 SubInsertTestItem1 { get; set; }
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
public List<SubInsertTestItem2> SubInsertTestItem2 { get; set; }
|
||||
}
|
||||
|
||||
public class SubInsertTestItem
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, OracleSequenceName = "Seq_id")]
|
||||
public int Id { get; set; }
|
||||
public int TestId { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public class SubInsertTestItem1
|
||||
{
|
||||
public string a { get; set; }
|
||||
}
|
||||
public class SubInsertTestItem2
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public int xid { get; set; }
|
||||
public string a { get; set; }
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@
|
||||
<Compile Include="Models\MyCustomAttributeTable.cs" />
|
||||
<Compile Include="Models\Order.cs" />
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Models\SubInsertTest.cs" />
|
||||
<Compile Include="Models\TestTree.cs" />
|
||||
<Compile Include="Models\Tree.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
|
@ -204,7 +204,9 @@ namespace SqlSugar
|
||||
continue;
|
||||
if (!string.IsNullOrEmpty(item.OracleSequenceName)&&this.Context.CurrentConnectionConfig.DbType==DbType.Oracle)
|
||||
{
|
||||
pkValue = "{SugarSeq:=}"+item.OracleSequenceName+ ".nextval{SugarSeq:=}";
|
||||
var value = "{SugarSeq:=}"+item.OracleSequenceName+ ".nextval{SugarSeq:=}";
|
||||
insertDictionary.Add(item.DbColumnName, value);
|
||||
continue;
|
||||
}
|
||||
if (item.PropertyInfo.Name == key)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user