Пример #1
0
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="tableColumnsEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseTableColumnsEntity tableColumnsEntity)
 {
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldTableCode, tableColumnsEntity.TableCode);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldColumnCode, tableColumnsEntity.ColumnCode);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldColumnName, tableColumnsEntity.ColumnName);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldIsPublic, tableColumnsEntity.IsPublic);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldEnabled, tableColumnsEntity.Enabled);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldAllowEdit, tableColumnsEntity.AllowEdit);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldAllowDelete, tableColumnsEntity.AllowDelete);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldDeletionStateCode, tableColumnsEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldSortCode, tableColumnsEntity.SortCode);
     sqlBuilder.SetValue(BaseTableColumnsEntity.FieldDescription, tableColumnsEntity.Description);
     SetEntityExpand(sqlBuilder, tableColumnsEntity);
 }
Пример #2
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="baseTableColumnsEntity">实体</param>
        public int UpdateEntity(BaseTableColumnsEntity baseTableColumnsEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, baseTableColumnsEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseTableColumnsEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseTableColumnsEntity.FieldId, baseTableColumnsEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Пример #3
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseTableColumnsEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseTableColumnsEntity baseTableColumnsEntity)
 {
     return(this.AddEntity(baseTableColumnsEntity));
 }
Пример #4
0
 partial void SetEntityExpand(SQLBuilder sqlBuilder, BaseTableColumnsEntity tableColumnsEntity);
Пример #5
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">主键</param>
        public BaseTableColumnsEntity GetEntity(int id)
        {
            BaseTableColumnsEntity baseTableColumnsEntity = new BaseTableColumnsEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseTableColumnsEntity.FieldId, id)));

            return(baseTableColumnsEntity);
        }
Пример #6
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="baseTableColumnsEntity">实体</param>
        public string AddEntity(BaseTableColumnsEntity baseTableColumnsEntity)
        {
            string sequence = string.Empty;

            if (baseTableColumnsEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                baseTableColumnsEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseTableColumnsEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldId, baseTableColumnsEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DbHelper.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseTableColumnsEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(BaseTableColumnsEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == CurrentDbType.Oracle || DbHelper.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (baseTableColumnsEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            baseTableColumnsEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseTableColumnsEntity.FieldId, baseTableColumnsEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, baseTableColumnsEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseTableColumnsEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseTableColumnsEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseTableColumnsEntity.FieldModifiedOn);
            if (DbHelper.CurrentDbType == CurrentDbType.SqlServer && this.Identity)
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
Пример #7
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseTableColumnsEntity">实体</param>
 public int Update(BaseTableColumnsEntity baseTableColumnsEntity)
 {
     return(this.UpdateEntity(baseTableColumnsEntity));
 }
Пример #8
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseTableColumnsEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseTableColumnsEntity baseTableColumnsEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(baseTableColumnsEntity));
 }
Пример #9
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="entity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseTableColumnsEntity entity)
 {
     return(this.AddObject(entity));
 }
Пример #10
0
 partial void SetObjectExpand(SQLBuilder sqlBuilder, BaseTableColumnsEntity entity);
Пример #11
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">实体</param>
 public int Update(BaseTableColumnsEntity entity)
 {
     return(this.UpdateObject(entity));
 }