zoukankan      html  css  js  c++  java
  • Update list item using Linq to SharePoint

    1. Update

    // Set the property to a new value.
    foreach (TeamMember teamMember in teamSite.TeamMembers)
    {
    teamMember.TopTask = "Fiscal Planning";
    }

    // Write changes to the content database.
    teamSite.SubmitChanges();

    2.Resolve Conflict

    foreach (TeamMember teamMember in teamSite.TeamMembers)
    {
    teamMember.TopTask = "Fiscal Planning";
    }

    try
    {
    teamSite.SubmitChanges();
    }
    catch (ChangeConflictException e)
    {
    teamSite.ChangeConflicts.ResolveAll();
    teamSite.SubmitChanges();
    }
    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




  • 相关阅读:
    case when in sql server's stored procedure
    Hadoop-2.2.0中国文献—— MapReduce 下一代 -- 公平调度
    cocos2d-x游戏循环和日程安排
    归并+高速分拣
    【Nginx】启动过程
    IOS线程操作(3)
    Android最方便的数据库--LitePal
    Android采用Application总结一下
    POJ 2151 Check the difficulty of problems (动态规划-可能DP)
    乞讨N!到底有多少0
  • 原文地址:https://www.cnblogs.com/windy2008/p/2320615.html
Copyright © 2011-2022 走看看