public override void CreateTopicStatus(IEnumerable<int> threadIDs, TopicStatuType type, DateTime endDate) { using (SqlQuery query = new SqlQuery()) { StringBuilder sql = new StringBuilder(); int i = 0; foreach (int threadID in threadIDs) { sql.AppendFormat(@" IF EXISTS(SELECT * FROM [bx_TopicStatus] WHERE ThreadID = @ThreadID_{0} AND Type = @Type) UPDATE [bx_TopicStatus] SET [EndDate] = @EndDate WHERE ThreadID = @ThreadID_{0} AND Type = @Type; ELSE INSERT INTO [bx_TopicStatus](ThreadID,Type,EndDate) VALUES(@ThreadID_{0},@Type,@EndDate); ", i); query.CreateParameter<int>("@ThreadID_" + i, threadID, SqlDbType.Int); i++; } query.CreateParameter<int>("Type", (int)type, SqlDbType.TinyInt); query.CreateParameter<DateTime>("EndDate", endDate, SqlDbType.DateTime); query.CommandText = sql.ToString(); query.CommandType = CommandType.Text; query.ExecuteNonQuery(); } }
public abstract void CreateTopicStatus(IEnumerable <int> threadIDs, TopicStatuType type, DateTime endDate);
public override void DeleteTopicStatus(IEnumerable<int> threadIDs, TopicStatuType type) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "DELETE [bx_TopicStatus] WHERE ThreadID IN(@ThreadIDs) AND Type=@Type;"; query.CommandType = CommandType.Text; query.CommandTimeout = int.MaxValue; query.CreateInParameter<int>("@ThreadIDs", threadIDs); query.CreateParameter<int>("@Type", (int)type, SqlDbType.TinyInt); query.ExecuteNonQuery(); } }
public abstract void DeleteTopicStatus(IEnumerable <int> threadIDs, TopicStatuType type);