我有一个包含排队元素的表,用于与另一个系统的同步问题
TableName | PrimaryKey | Action -------------------------------- Products 15 Delete Products 21 Create Categories 9 Update
PrimaryKey:相应表中目标元素的PK值
操作:要执行的操作(示例:如果创建 – >推送创建远程系统中本地表产品的ID号为21的元素)
我需要的是一种在C#中正确处理这个问题的方法.我正在考虑使用命令模式. (ASP.Net MVC4 / C#)
你对这类问题有什么指导吗?
解决方法
您可以使用
that article中的建议和服务器端的进程队列.然后你的代码看起来像
create table TQueue (TableName nvarchar(128),PrimaryKey int,Action nvarchar(128)) create procedure sp_TQueue_Pop as begin declare @TableName nvarchar(128),@PrimaryKey int,@Action nvarchar(128) declare @temp_pop table (TableName nvarchar(128),Action nvarchar(128)) begin transaction select @TableName = null,@PrimaryKey = null,@Action = null delete top (1) from TQueue with (rowlock,readpast) output deleted.* into @temp_pop select @TableName = TableName,@PrimaryKey = PrimaryKey,@Action = Action from @temp_pop --================================================ -- do your processing here --================================================ select @TableName,@PrimaryKey,@Action end
出列你刚刚执行程序.
希望有所帮助.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。