删除操作包括简单的删除、启用事务删除、模糊匹配和批量删除、多个条件组合删除等操作。
DeleteContents
删除——模糊匹配,区域范围匹配等批量删除
示例
public bool Delete_Test() {
SetSql(new DataObject.Param.Filter()
{
Mark = ">",
Value = new LotteryModel() { Lot_id=11151 }
});
return this.Delete();
}
public bool Delete_Test() {
SetSql(new DataObject.Param.Filter()
{
Mark = "like",
Value = new LotteryModel() { Lot_title="20140301" }
});
return this.Delete();
SetSql(new DataObject.Param.Filter()
{
Mark = ">",
Value = new LotteryModel() { Lot_id=11151 }
});
return this.Delete();
}
public bool Delete_Test() {
SetSql(new DataObject.Param.Filter()
{
Mark = "like",
Value = new LotteryModel() { Lot_title="20140301" }
});
return this.Delete();
删除——多个条件组合
示例
/// 测试-删除多条件Or关联
public bool Delete_Test2() {
SetSql(new DataObject.Param.Filter[]{
new DataObject.Param.Filter(){
Mark="=", Value = new LotteryModel(){ Lot_id = 11151 }
}
}, new DataObject.Param.Filter[]{
new DataObject.Param.Filter(){
Mark="=", Value=new LotteryModel(){Lot_title="测试8"}
}
});
return this.Delete();
}
public bool Delete_Test2() {
SetSql(new DataObject.Param.Filter[]{
new DataObject.Param.Filter(){
Mark="=", Value = new LotteryModel(){ Lot_id = 11151 }
}
}, new DataObject.Param.Filter[]{
new DataObject.Param.Filter(){
Mark="=", Value=new LotteryModel(){Lot_title="测试8"}
}
});
return this.Delete();
}
删除——同类型实体不同更新值
示例
LotteryModel lottery = new LotteryModel() {
Lot_id = 11150
};
lottery.Items = new List();
lottery.Items.Add(new LotteryModel() { Lot_id = 11149 });
lottery.Items.Add(new LotteryModel() { Lot_id = 11148 });
lottery.Delete();
Lot_id = 11150
};
lottery.Items = new List();
lottery.Items.Add(new LotteryModel() { Lot_id = 11149 });
lottery.Items.Add(new LotteryModel() { Lot_id = 11148 });
lottery.Delete();
删除——同类型实体不同更新值
示例
Sql[] sql = new Sql[2];
//删除
sql[0] = new Sql()
{
Parameter = new LotteryModel[]{
new LotteryModel(){ Lot_id=11153 }
}
};
//添加
sql[1] = new Sql(){
ExecuteType= DataObject.Enum.ExecuteType.Create,
Parameter = new LotteryModel[]{
new LotteryModel()
{
Lot_id=0,
Lot_code = "07,02,01,04,06",
Lot_guess = "test2",
Lot_platform = 3,
Lot_type = 0,
Lot_title = "测试9",
SetDate=DateTime.Now
}
}
};
LotteryModel lottery = new LotteryModel();
lottery.Delete(true, sql);
//删除
sql[0] = new Sql()
{
Parameter = new LotteryModel[]{
new LotteryModel(){ Lot_id=11153 }
}
};
//添加
sql[1] = new Sql(){
ExecuteType= DataObject.Enum.ExecuteType.Create,
Parameter = new LotteryModel[]{
new LotteryModel()
{
Lot_id=0,
Lot_code = "07,02,01,04,06",
Lot_guess = "test2",
Lot_platform = 3,
Lot_type = 0,
Lot_title = "测试9",
SetDate=DateTime.Now
}
}
};
LotteryModel lottery = new LotteryModel();
lottery.Delete(true, sql);
删除——不同实体
示例
Sql[] sql = new Sql[2];
sql[0] = new Sql()
{
Parameter = new LotteryModel[] { new LotteryModel() { Lot_id = 11157 } }
};
sql[1] = new Sql() {
Parameter = new CodeModel[] { new CodeModel() { C_id = 1 } }
};
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Delete(true, sql);
sql[0] = new Sql()
{
Parameter = new LotteryModel[] { new LotteryModel() { Lot_id = 11157 } }
};
sql[1] = new Sql() {
Parameter = new CodeModel[] { new CodeModel() { C_id = 1 } }
};
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Delete(true, sql);
删除——不同实体不同操作
示例
Sql[] sql = new Sql[2];
sql[0] = new Sql()
{
Parameter = new CodeModel[] { new CodeModel() { C_id = 2 } }
};
sql[1] = new Sql()
{
ExecuteType= DataObject.Enum.ExecuteType.Create,
Parameter = new LotteryModel[]{
new LotteryModel()
{
Lot_id=0,
Lot_code = "07,04,01,04,06",
Lot_guess = "test2",
Lot_platform = 3,
Lot_type = 0,
Lot_title = "test002",
SetDate=DateTime.Now
}
}
};
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Delete(true, sql);
sql[0] = new Sql()
{
Parameter = new CodeModel[] { new CodeModel() { C_id = 2 } }
};
sql[1] = new Sql()
{
ExecuteType= DataObject.Enum.ExecuteType.Create,
Parameter = new LotteryModel[]{
new LotteryModel()
{
Lot_id=0,
Lot_code = "07,04,01,04,06",
Lot_guess = "test2",
Lot_platform = 3,
Lot_type = 0,
Lot_title = "test002",
SetDate=DateTime.Now
}
}
};
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Delete(true, sql);