/// <summary> /// 更新实体 /// </summary> /// <param name="entity">实体</param> public int UpdateObject(BaseUserAddressEntity entity) { SQLBuilder sqlBuilder = new SQLBuilder(DbHelper); sqlBuilder.BeginUpdate(this.CurrentTableName); this.SetObject(sqlBuilder, entity); if (UserInfo != null) { sqlBuilder.SetValue(BaseUserAddressEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseUserAddressEntity.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseUserAddressEntity.FieldModifiedOn); sqlBuilder.SetWhere(BaseUserAddressEntity.FieldId, entity.Id); return(sqlBuilder.EndUpdate()); }
/// <summary> /// 设置实体 /// </summary> /// <param name="userAddressEntity">实体</param> private void SetEntity(SQLBuilder sqlBuilder, BaseUserAddressEntity userAddressEntity) { sqlBuilder.SetValue(BaseUserAddressEntity.FieldUserId, userAddressEntity.UserId); sqlBuilder.SetValue(BaseUserAddressEntity.FieldRealName, userAddressEntity.RealName); sqlBuilder.SetValue(BaseUserAddressEntity.FieldProvinceId, userAddressEntity.ProvinceId); sqlBuilder.SetValue(BaseUserAddressEntity.FieldProvince, userAddressEntity.Province); sqlBuilder.SetValue(BaseUserAddressEntity.FieldCityId, userAddressEntity.CityId); sqlBuilder.SetValue(BaseUserAddressEntity.FieldCity, userAddressEntity.City); sqlBuilder.SetValue(BaseUserAddressEntity.FieldAreaId, userAddressEntity.AreaId); sqlBuilder.SetValue(BaseUserAddressEntity.FieldArea, userAddressEntity.Area); sqlBuilder.SetValue(BaseUserAddressEntity.FieldAddress, userAddressEntity.Address); sqlBuilder.SetValue(BaseUserAddressEntity.FieldPostCode, userAddressEntity.PostCode); sqlBuilder.SetValue(BaseUserAddressEntity.FieldPhone, userAddressEntity.Phone); sqlBuilder.SetValue(BaseUserAddressEntity.FieldFax, userAddressEntity.Fax); sqlBuilder.SetValue(BaseUserAddressEntity.FieldMobile, userAddressEntity.Mobile); sqlBuilder.SetValue(BaseUserAddressEntity.FieldEmail, userAddressEntity.Email); sqlBuilder.SetValue(BaseUserAddressEntity.FieldDeliverCategory, userAddressEntity.DeliverCategory); sqlBuilder.SetValue(BaseUserAddressEntity.FieldSortCode, userAddressEntity.SortCode); sqlBuilder.SetValue(BaseUserAddressEntity.FieldDeletionStateCode, userAddressEntity.DeletionStateCode); sqlBuilder.SetValue(BaseUserAddressEntity.FieldEnabled, userAddressEntity.Enabled); sqlBuilder.SetValue(BaseUserAddressEntity.FieldDescription, userAddressEntity.Description); SetEntityExpand(sqlBuilder, userAddressEntity); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">实体</param> /// <returns>主键</returns> public string Add(BaseUserAddressEntity entity) { return(this.AddObject(entity)); }
partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseUserAddressEntity entity);
/// <summary> /// 添加实体 /// </summary> /// <param name="entity">实体</param> public string AddObject(BaseUserAddressEntity entity) { string sequence = string.Empty; sequence = entity.Id; if (entity.SortCode == 0) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.Increment(this.CurrentTableName); entity.SortCode = int.Parse(sequence); } SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId); sqlBuilder.BeginInsert(this.CurrentTableName, BaseUserAddressEntity.FieldId); if (entity.Id is string) { this.Identity = false; } if (!this.Identity) { sqlBuilder.SetValue(BaseUserAddressEntity.FieldId, entity.Id); } else { if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2)) { if (DbHelper.CurrentDbType == CurrentDbType.Oracle) { sqlBuilder.SetFormula(BaseUserAddressEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL "); } if (DbHelper.CurrentDbType == CurrentDbType.DB2) { sqlBuilder.SetFormula(BaseUserAddressEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper()); } } else { if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2)) { if (string.IsNullOrEmpty(entity.Id)) { if (string.IsNullOrEmpty(sequence)) { BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity); sequence = sequenceManager.Increment(this.CurrentTableName); } entity.Id = sequence; } sqlBuilder.SetValue(BaseUserAddressEntity.FieldId, entity.Id); } } } this.SetObject(sqlBuilder, entity); if (UserInfo != null) { sqlBuilder.SetValue(BaseUserAddressEntity.FieldCreateUserId, UserInfo.Id); sqlBuilder.SetValue(BaseUserAddressEntity.FieldCreateBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseUserAddressEntity.FieldCreateOn); if (UserInfo != null) { sqlBuilder.SetValue(BaseUserAddressEntity.FieldModifiedUserId, UserInfo.Id); sqlBuilder.SetValue(BaseUserAddressEntity.FieldModifiedBy, UserInfo.RealName); } sqlBuilder.SetDBNow(BaseUserAddressEntity.FieldModifiedOn); if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity) { sequence = sqlBuilder.EndInsert().ToString(); } else { sqlBuilder.EndInsert(); } return(sequence); }
/// <summary> /// 更新 /// </summary> /// <param name="entity">实体</param> public int Update(BaseUserAddressEntity entity) { return(this.UpdateObject(entity)); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">实体</param> /// <param name="identity">自增量方式</param> /// <param name="returnId">返回主鍵</param> /// <returns>主键</returns> public string Add(BaseUserAddressEntity entity, bool identity, bool returnId) { this.Identity = identity; this.ReturnId = returnId; return(this.AddObject(entity)); }
/// <summary> /// 添加 /// </summary> /// <param name="userAddressEntity">实体</param> /// <returns>主键</returns> public string Add(BaseUserAddressEntity userAddressEntity) { return(this.AddEntity(userAddressEntity)); }
partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseUserAddressEntity userAddressEntity);
/// <summary> /// 获取实体 /// </summary> /// <param name="id">主键</param> public BaseUserAddressEntity GetEntity(string id) { BaseUserAddressEntity userAddressEntity = new BaseUserAddressEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseUserAddressEntity.FieldId, id))); return(userAddressEntity); }
/// <summary> /// 更新 /// </summary> /// <param name="userAddressEntity">实体</param> public int Update(BaseUserAddressEntity userAddressEntity) { return(this.UpdateEntity(userAddressEntity)); }