mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-26 18:59:17 +08:00
Add Insertable.CallEntityMethod
Add Updateable.CallEntityMethod
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
<Compile Include="UnitTest\Test01.cs" />
|
||||
<Compile Include="UnitTest\UEnum.cs" />
|
||||
<Compile Include="UnitTest\UFilter.cs" />
|
||||
<Compile Include="UnitTest\UInsert2.cs" />
|
||||
<Compile Include="UnitTest\UInsert.cs" />
|
||||
<Compile Include="UnitTest\UQueryable2.cs" />
|
||||
<Compile Include="UnitTest\UQueue.cs" />
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace OrmTest
|
||||
{
|
||||
Filter();
|
||||
Insert();
|
||||
Insert2();
|
||||
Enum();
|
||||
Tran();
|
||||
Queue();
|
||||
|
||||
43
Src/Asp.Net/SqlServerTest/UnitTest/UInsert2.cs
Normal file
43
Src/Asp.Net/SqlServerTest/UnitTest/UInsert2.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public partial class NewUnitTest
|
||||
{
|
||||
public static void Insert2()
|
||||
{
|
||||
var db = Db;
|
||||
db.CodeFirst.InitTables<UnitInsertMethod>();
|
||||
db.Insertable(new UnitInsertMethod() { Name = "1" }).CallEntityMethod(it=>it.Create()).ExecuteCommand();
|
||||
db.Insertable(new UnitInsertMethod() { Name = "2" }).CallEntityMethod(it => it.Create("admin")).ExecuteCommand();
|
||||
db.Updateable(new UnitInsertMethod() {Id=1, Name = "1" }).CallEntityMethod(it => it.Create()).ExecuteCommand();
|
||||
db.Updateable(new UnitInsertMethod() { Name = "1" }).CallEntityMethod(it => it.Create("admint")).ExecuteCommand();
|
||||
}
|
||||
|
||||
public class UnitInsertMethod
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
[SqlSugar.SugarColumn(IsNullable =true)]
|
||||
public string UserId { get; set; }
|
||||
|
||||
public void Create()
|
||||
{
|
||||
this.Time = DateTime.Now;
|
||||
this.UserId = "1";
|
||||
}
|
||||
public void Create(string a)
|
||||
{
|
||||
this.Time = DateTime.Now;
|
||||
this.UserId = a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user