/// <summary>
 /// 为了提高授权的运行速度
 /// </summary>
 /// <param name="Id">主键</param>
 /// <param name="userId">用户主键</param>
 /// <param name="roleId">角色主键</param>
 /// <returns>主键</returns>
 public string AddToRole(string userId, string roleId)
 {
     string returnValue = string.Empty;
     BaseUserRoleEntity userRoleEntity = new BaseUserRoleEntity();
     userRoleEntity.UserId = int.Parse(userId);
     userRoleEntity.RoleId = int.Parse(roleId);
     userRoleEntity.Enabled = 1;
     userRoleEntity.DeletionStateCode = 0;
     string tableName = BaseUserRoleEntity.TableName;
     if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
     {
         tableName = BaseSystemInfo.SystemCode + "UserRole";
     }
     BaseUserRoleManager userRoleManager = new BaseUserRoleManager(this.DbHelper, this.UserInfo, tableName);
     return userRoleManager.Add(userRoleEntity);
 }
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseUserRoleEntity userRoleEntity);
 /// <summary>
 /// 更新实体
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 public int UpdateEntity(BaseUserRoleEntity userRoleEntity)
 {
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);
     sqlBuilder.BeginUpdate(this.CurrentTableName);
     this.SetEntity(sqlBuilder, userRoleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldModifiedOn);
     sqlBuilder.SetWhere(BaseUserRoleEntity.FieldId, userRoleEntity.Id);
     return sqlBuilder.EndUpdate();
 }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseUserRoleEntity userRoleEntity)
 {
     sqlBuilder.SetValue(BaseUserRoleEntity.FieldUserId, userRoleEntity.UserId);
     sqlBuilder.SetValue(BaseUserRoleEntity.FieldRoleId, userRoleEntity.RoleId);
     sqlBuilder.SetValue(BaseUserRoleEntity.FieldEnabled, userRoleEntity.Enabled);
     sqlBuilder.SetValue(BaseUserRoleEntity.FieldDescription, userRoleEntity.Description);
     sqlBuilder.SetValue(BaseUserRoleEntity.FieldDeletionStateCode, userRoleEntity.DeletionStateCode);
     SetEntityExpand(sqlBuilder, userRoleEntity);
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 public int Update(BaseUserRoleEntity userRoleEntity)
 {
     return this.UpdateEntity(userRoleEntity);
 }
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <param name="id">主键</param>
 public BaseUserRoleEntity GetEntity(int id)
 {
     BaseUserRoleEntity userRoleEntity = new BaseUserRoleEntity(this.GetDataTable(new KeyValuePair<string, object>(BaseUserRoleEntity.FieldId, id)));
     return userRoleEntity;
 }
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 public string AddEntity(BaseUserRoleEntity userRoleEntity)
 {
     string sequence = string.Empty;
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);
     sqlBuilder.BeginInsert(this.CurrentTableName, BaseUserRoleEntity.FieldId);
     if (!this.Identity)
     {
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, userRoleEntity.Id);
     }
     else
     {
         if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
         {
             if (DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
             }
             if (DbHelper.CurrentDbType == DbTypes.DB2)
             {
                 sqlBuilder.SetFormula(BaseUserRoleEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
             }
         }
         else
         {
             if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
             {
                 if (userRoleEntity.Id == null)
                 {
                     if (string.IsNullOrEmpty(sequence))
                     {
                         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                         sequence = sequenceManager.GetSequence(this.CurrentTableName);
                     }
                     userRoleEntity.Id = int.Parse(sequence);
                 }
                 sqlBuilder.SetValue(BaseUserRoleEntity.FieldId, userRoleEntity.Id);
             }
         }
     }
     this.SetEntity(sqlBuilder, userRoleEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldCreateBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldCreateOn);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseUserRoleEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseUserRoleEntity.FieldModifiedOn);
     if (DbHelper.CurrentDbType == DbTypes.SqlServer && this.Identity)
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主鍵</param>
 /// <returns>主键</returns>
 public string Add(BaseUserRoleEntity userRoleEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return this.AddEntity(userRoleEntity);
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="userRoleEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseUserRoleEntity userRoleEntity)
 {
     return this.AddEntity(userRoleEntity);
 }