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

entity.Update—实体修改操作

  实体修改操作包括简单的修改操作、启用事务的简单修改操作、模糊匹配修改操作、批量更新、多个条件组合、相同与不同实体的更新操作等。

Update
修改——简单示例(非严谨性数据)

示例

LotteryModel lottery = new LotteryModel() {
    Lot_id=5,
    Lot_code="01,02,03"
  };
  lottery.Update();
修改——简单示例启用事务

示例

LotteryModel lottery = new LotteryModel() {
  Lot_id = 11153,
  Lot_code="01,02,03"
};
lottery.Update(true);
修改——模糊匹配,区域范围匹配等批量更新

示例

// 测试--修改
public bool Update_Test() {
  SetSql(new DataObject.Param.Filter()
  {
    Mark = ">",
    Value = new LotteryModel() { Lot_id=100 }
  });
  this.Lot_type = 0;
  //this.Lot_id = 11130;
  return this.Update();
}
// 测试--修改模糊匹配
public bool Update_Test() {
  SetSql(new DataObject.Param.Filter()
  {
    Mark = "like",
    Value = new LotteryModel() { Lot_title="20140301" }
  });
  this.Lot_type = 0;
  return this.Update();
}
修改——多个条件组合

示例

//测试-修改多条件Or关联
public bool Update_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"}
    }
  });
  this.Lot_code = "02,3,4";
  return this.Update();
}
修改——同类型实体不同更新值

示例

LotteryModel lottery = new LotteryModel() {
  Lot_id = 11150,
  Lot_code="32,31,30"
};
lottery.Items = new List();
lottery.Items.Add(new LotteryModel() {Lot_id=11149,Lot_code="11,12,13"});
lottery.Update();
修改——同类型实体不同更新值

示例

Sql[] sql = new Sql[2];
  //更新
  sql[0] = new Sql()
  {
    Parameter = new LotteryModel[]{
      new LotteryModel()
      {
        Lot_id=11153,
        Lot_code = "07,02,06,04,01",
        Lot_platform = 3,
        Lot_type = 0,
        Lot_title = "测试9"
      }
    }
  };
  //添加
  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.Update(true, sql);
修改——不同实体操作

示例

Sql[] sql = new Sql[2];
  sql[0] = new Sql()
  {
    Parameter = new LotteryModel[]{
      new LotteryModel()
      {
        Lot_id=11155,
        Lot_code = "07,04,01,04,06",
        Lot_guess = "test2",
        Lot_platform = 3,
        Lot_type = 0,
        Lot_title = "测试7",
        SetDate=DateTime.Now
      }
    }
  };
  sql[1] = new Sql(){
    Parameter = new CodeModel[]{
      new CodeModel()
      {
        C_id=1,
        Bewrite="320132013"
      }
    }
  };
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Update(true, sql);
修改——不同实体不同更新值

示例

Sql[] sql = new Sql[2];
  sql[0] = new Sql()
  {
    Parameter = new CodeModel[]{
      new CodeModel()
      {
        C_id=1,
        Bewrite="320132015"
      }
    }
  };
  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 = "test001",
        SetDate=DateTime.Now
      }
    }
  };
//使用基类进行操作
DataObject.DataFactory.DataModulemodule = new DataObject.DataFactory.DataModule();
module.Update(true, sql);
开始使用| 文档| 演示/教程| 独立组件| 社区 快递查询 Copyright © 2016 - 2017 tiaoceng.com All Rights Reserved