开始使用 文档 演示/教程 独立组件 社区
全部分类 实体操作 脚本控件

entity.Delete—实体删除操作

  删除操作包括简单的删除、启用事务删除、模糊匹配和批量删除、多个条件组合删除等操作。

Delete
删除——简单示例(非严谨性数据)

示例

new LotteryModel() { Lot_id = 11155 }.Delete();
修改——简单示例启用事务

示例

new LotteryModel() { Lot_id = 11155 }.Delete(true);
删除——模糊匹配,区域范围匹配等批量删除

示例

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();
删除——多个条件组合

示例

/// 测试-删除多条件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();
}
删除——同类型实体不同更新值

示例

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();
删除——同类型实体不同更新值

示例

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[] 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[] 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);
开始使用| 文档| 演示/教程| 独立组件| 社区 快递查询 Copyright © 2016 - 2017 tiaoceng.com All Rights Reserved