/// <summary> /// 插入数据 /// </summary> /// <param name = "item">要插入的实体对象</param> /// <param name="tm">事务管理对象</param> /// <return>受影响的行数</return> public virtual int Add(UsercountEO item, TransactionManager tm = null) { const string sql = @"INSERT INTO usercount (userId, openId, leftTimes, giveTimes) VALUES (@userId, @openId, @leftTimes, @giveTimes) "; return(Database.CreateSqlDao(sql) .AddInParameter("@userId", item.UserId, DbType.Int32, 0) .AddInParameter("@openId", item.OpenId != null ? (object)item.OpenId : DBNull.Value, DbType.String, 300) .AddInParameter("@leftTimes", item.LeftTimes.HasValue ? (object)item.LeftTimes.Value : DBNull.Value, DbType.Int32, 0) .AddInParameter("@giveTimes", item.GiveTimes.HasValue ? (object)item.GiveTimes.Value : DBNull.Value, DbType.Int32, 0) .ExecNonQuery(tm)); }
/// <summary> /// 更新数据 /// </summary> /// <param name = "item">要更新的实体对象</param> /// <param name="tm">事务管理对象</param> /// <return>受影响的行数</return> public virtual int Put(UsercountEO item, TransactionManager tm = null) { const string sql = @"UPDATE usercount SET userId=@userId, openId=@openId, leftTimes=@leftTimes, giveTimes=@giveTimes WHERE userId=@OriginalUserId"; return(Database.CreateSqlDao(sql) .AddInParameter("@OriginalUserId", (item.HasOriginal) ? item.OriginalUserId : item.UserId, DbType.Int32, 0) .AddInParameter("@userId", item.UserId, DbType.Int32, 0) .AddInParameter("@openId", item.OpenId != null ? (object)item.OpenId : DBNull.Value, DbType.String, 300) .AddInParameter("@leftTimes", item.LeftTimes.HasValue ? (object)item.LeftTimes.Value : DBNull.Value, DbType.Int32, 0) .AddInParameter("@giveTimes", item.GiveTimes.HasValue ? (object)item.GiveTimes.Value : DBNull.Value, DbType.Int32, 0) .ExecNonQuery(tm)); }
/// <summary> /// 删除指定实体对应的记录 /// </summary> /// <param name = "item">要删除的实体</param> /// <param name="tm">事务管理对象</param> /// <return>受影响的行数</return> public virtual int Remove(UsercountEO item, TransactionManager tm = null) { return(RemoveByPK(item.UserId, tm)); }