Ejemplo n.º 1
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name = "item">要插入的实体对象</param>
        /// <param name="tm">事务管理对象</param>
        /// <return>受影响的行数</return>
        public virtual int Add(UserblacklistEO item, TransactionManager tm = null)
        {
            const string sql = @"INSERT INTO userblacklist (userId, blackUserId, addTime) VALUES (@userId, @blackUserId, @addTime)";

            item.Id = int.Parse(Database.CreateSqlDao(sql)
                                .AddInParameter("@userId", item.UserId != null ?  (object)item.UserId : DBNull.Value, DbType.String, 60)
                                .AddInParameter("@blackUserId", item.BlackUserId != null ?  (object)item.BlackUserId : DBNull.Value, DbType.String, 60)
                                .AddInParameter("@addTime", item.AddTime != null ?  (object)item.AddTime : DBNull.Value, DbType.String, 60)
                                .ExecScalar(tm).ToString());
            return(1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name = "item">要更新的实体对象</param>
        /// <param name="tm">事务管理对象</param>
        /// <return>受影响的行数</return>
        public virtual int Put(UserblacklistEO item, TransactionManager tm = null)
        {
            const string sql = @"UPDATE userblacklist SET userId=@userId, blackUserId=@blackUserId, addTime=@addTime WHERE id=@OriginalId";

            return(Database.CreateSqlDao(sql)
                   .AddInParameter("@OriginalId", (item.HasOriginal) ? item.OriginalId : item.Id, DbType.Int32, 0)
                   .AddInParameter("@userId", item.UserId != null ?  (object)item.UserId : DBNull.Value, DbType.String, 60)
                   .AddInParameter("@blackUserId", item.BlackUserId != null ?  (object)item.BlackUserId : DBNull.Value, DbType.String, 60)
                   .AddInParameter("@addTime", item.AddTime != null ?  (object)item.AddTime : DBNull.Value, DbType.String, 60)
                   .ExecNonQuery(tm));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 删除指定实体对应的记录
 /// </summary>
 /// <param name = "item">要删除的实体</param>
 /// <param name="tm">事务管理对象</param>
 /// <return>受影响的行数</return>
 public virtual int Remove(UserblacklistEO item, TransactionManager tm = null)
 {
     return(RemoveByPK(item.Id, tm));
 }