在 Silverlight 应用程序中,我使用存储过程来更新我的数据库表。
ALTER PROCEDURE [dbo].[SP_ADD_MIS_MISSION]
(
@IdMission as int,
@IdVersion as smallint,
@LibMission as varchar (50)
)
AS
BEGIN
DECLARE @IDNEWVERSION as int = 1,
@IDNEWMISSION as int = @IdMission,
@supp as bit = 1
BEGIN
IF @IdMission != 0 AND @IdMission is not NULL
BEGIN
SELECT @IDNEWVERSION = MAX(IDVERSION)+1 FROM MIS_Mission where MIS_Mission.IdMission=@IdMission
Update MIS_Mission SET Suppression = @supp WHERE MIS_Mission.IdMission=@IdMission AND MIS_Mission.IdVersion=(@IDNEWVERSION-1)
END
ELSE
BEGIN
SET @IDNEWVERSION = 1
select @IDNEWMISSION = MAX(MIS_Mission.IdMission)+1 from MIS_Mission
if @IDNEWMISSION is NULL SET @IDNEWMISSION=1
END
Insert MIS_Mission ( IdMission,
IdVersion,
LibMission,
Suppression
)
values ( @IDNEWMISSION,
@IDNEWVERSION,
@LibMission,
@Suppression
)
SELECT @IDNEWMISSION
END
我在我的 WCF RIA 服务中添加了这段代码来启动存储过程:
public void SetMission(MIS_Mission mis)
{
_entity.ADD_MIS_MISSION(mis.IdMission,mis.IdVersion,mis.LibMission);
}
我在我的 Silverlight 应用程序中添加了这段代码,以更新我的数据库,并在我的 datagrid 中输入值:
private void UpdateMission_Click(object sender, RoutedEventArgs e)
{
foreach(MIS_Mission mis in dG_Mission.ItemsSource)
{
var operation = _Context.SetMission(mis);
operation.Completed += (se, ev) =>
{
};
}
}
但是当我完成数据库更新时,我的上下文并没有更新 IdVersion 的新值,并且我的数据网格显示了我的任务的旧版本。
如何在不重新加载数据网格的情况下更新上下文?