public void DeleteByKey(object keyValue) { if (this.keyName == null || this.keyName.Trim().Length == 0) { throw new Exception(string.Format("表{0}不存在主键", keyName)); } if (keyValue == null) { throw new Exception("主键值不能为空"); } this.myDelete = new Delete_(); this.myDelete.Where().Equal(keyName, keyValue); AddDeleteObject(this.myDelete); }
private void AddDeleteObject(Delete_ iDelete) { DeleteObject deleteObject = new DeleteBuilder <T> .DeleteObject(); deleteObject.Delete = iDelete; if (tranBuilder != null) { deleteObject.CmdIndex = tranBuilder.GetCmdTextsCount(); // 在集合中站位,等创建脚本的时候再将内容填充 tranBuilder.AddCommondType(CommandType.Text); tranBuilder.AddCmdText(null); tranBuilder.AddCmdParam(null); } else { // 不是事务操作时,一次只操作一条语句 this.listDeleteObject.Clear(); deleteObject.CmdIndex = this.listDeleteObject.Count; } this.listDeleteObject.Add(deleteObject); }
public Delete_ Delete() { this.myDelete = new Delete_(); AddDeleteObject(this.myDelete); return(this.myDelete); }