2017-05-22 01:32:35 +08:00
|
|
|
|
using OrmTest.Models;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
2017-05-21 22:33:21 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace OrmTest.Demo
|
|
|
|
|
{
|
2017-05-29 01:30:23 +08:00
|
|
|
|
public class Delete:DemoBase
|
2017-05-21 22:33:21 +08:00
|
|
|
|
{
|
2017-05-22 01:32:35 +08:00
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
var db = GetInstance();
|
|
|
|
|
//by entity
|
|
|
|
|
var t1 = db.Deleteable<Student>().Where(new Student() { Id = 1 }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//use lock
|
|
|
|
|
var t2 = db.Deleteable<Student>().With(SqlWith.RowLock).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//by primary key
|
|
|
|
|
var t3 = db.Deleteable<Student>().In(1).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
//by primary key array
|
|
|
|
|
var t4 = db.Deleteable<Student>().In(new int[] { 1, 2 }).ExecuteCommand();
|
|
|
|
|
|
2017-07-02 23:53:01 +08:00
|
|
|
|
//by expression id>1 and id==1
|
|
|
|
|
var t5 = db.Deleteable<Student>().Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommand();
|
2017-09-05 13:01:10 +08:00
|
|
|
|
|
|
|
|
|
var t6 = db.Deleteable<Student>().AS("student").Where(it => it.Id > 1).Where(it => it.Id == 1).ExecuteCommandAsync();
|
|
|
|
|
t6.Wait();
|
2017-05-22 01:32:35 +08:00
|
|
|
|
}
|
2017-05-21 22:33:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|