ObjectChangeConflict.Resolve 方法 (RefreshMode)
通过指定每个字段和属性,这些属性的差异,一个值到下一次的SubmitChanges上的数据库保持不变,解决矛盾。
命名空间: Microsoft.SharePoint.Linq
程序集: Microsoft.SharePoint.Linq(位于 Microsoft.SharePoint.Linq.dll 中)
语法
声明
Public Sub Resolve ( _
refreshMode As RefreshMode _
)
用法
Dim instance As ObjectChangeConflict
Dim refreshMode As RefreshMode
instance.Resolve(refreshMode)
public void Resolve(
RefreshMode refreshMode
)
参数
refreshMode
类型:Microsoft.SharePoint.Linq.RefreshMode一个值,用于指定如何解决冲突。
备注
Resolve(RefreshMode)方法的此重载行为完全按照Resolve(RefreshMode, Boolean)与autoResolveDeletes参数设置为true。
示例
下面的示例演示如何在catch块中使用Resolve(RefreshMode) ,对ChangeConflictException进行响应:
foreach (TeamMember teamMember in teamSite.TeamMembers)
{
teamMember.TopTask = "Fiscal Planning";
}
try
{
teamSite.SubmitChanges(ConflictMode.ContinueOnConflict);
}
catch (ChangeConflictException e)
{
foreach (ObjectChangeConflict changedListItem in teamSite.ChangeConflicts)
{
// If another user has changed properties of a non-manager,
// leave that other user’s changes, except for the TopTask field.
if (((TeamMember)changedListItem.Object).IsManager = false)
{
foreach (MemberChangeConflict changedField in changedListItem.MemberConflicts)
{
if (changedField.Member.Name == "TopTask")
{
changedField.Resolve(RefreshMode.KeepCurrentValues);
}
else
{
changedField.Resolve(RefreshMode.OverwriteCurrentValues);
}
}
}
// But if another user has changed properties of a manager, let this
// process’s changes override the other user’s changes.
else
{
changedListItem.Resolve(RefreshMode.KeepCurrentValues);
}
}
teamSite.SubmitChanges();
} // end catch