using SqlSugar; using System; using System.Collections.Generic; using System.Data; using Uninpho.DBOperation.Model; namespace Uninpho.DBOperation.Operation { public class Demo3_Insertable { public static void Test() { SqlSugarClient db = Config.GetPgClient(); var insertObj = new User() { Id = 1, Name = "order1",Price=0 }; var updateObjs = new List { new User() { Id = 11, Name = "order11", Price=0 }, new User() { Id = 12, Name = "order12" , Price=0} }; //Only insert Name and Price db.Insertable(insertObj).InsertColumns(it => new { it.Name, it.Price }).ExecuteReturnIdentity(); db.Insertable(insertObj).InsertColumns("Name", "Price").ExecuteReturnIdentity(); //ignore null columns db.Insertable(updateObjs).ExecuteCommand();//get change row count //Use Lock db.Insertable(insertObj).With(SqlWith.UpdLock).ExecuteCommand(); Console.WriteLine("#### Insertable End ####"); } } }