首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过CAML提供ListInstance

通过CAML提供ListInstance
EN

Stack Overflow用户
提问于 2011-09-01 22:51:59
回答 2查看 805关注 0票数 0

在CAML2010中,当使用SharePoint提供列表时,是否可以不覆盖现有的ListInstance (假设它已经存在)?或者定制代码是必要的?

编辑:这个问题对我来说并不清楚。我应该注意到,我是通过一个使用默认vs2010构建/部署过程的解决方案来部署列表实例的。使用此过程时,列表实例将在我部署时被删除并重新创建。我试图防止它每次都被重新创建。

EN

回答 2

Stack Overflow用户

发布于 2011-09-02 21:16:52

不能,不能用ListInstance元素覆盖现有列表。您可以更改EnableVersioningHidden。您还可以通过数据/行/行添加项目。但是原始的列表仍然存在。

下面是来自Microsoft.SharePoint.SPListInstanceElement的"documentation“代码:

代码语言:javascript
复制
internal override void ElementActivated(SPFeaturePropertyCollection props, SPSqlCommand sqlcmdAppendOnly, SPWebApplication webApp, SPSite site, SPWeb web, bool fForce)
{
  bool flag1 = this.FeatureDefinition.Scope == SPFeatureScope.Site;
  bool flag2 = true;
  if (this.RootWebOnly && !web.IsRootWeb)
    flag2 = false;
  if (!flag2)
    return;
  this.EnsureDataProvisioned(this.EnsureListExists(!flag1 ? web : site.RootWeb));
}

internal SPList EnsureListExists(SPWeb web)
{
  SPList spList = web.Lists.GetListByName(this.Title, false);
  if (spList == null)
  {
    // SNIP - list would be created here
  }
  bool flag = false;
  if (this.VersioningEnabled.HasValue && spList.EnableVersioning != this.VersioningEnabled.Value)
  {
    spList.EnableVersioning = this.VersioningEnabled.Value;
    flag = true;
  }
  if (this.Hidden.HasValue && spList.Hidden != this.Hidden.Value)
  {
    spList.Hidden = this.Hidden.Value;
    flag = true;
  }
  if (flag)
    spList.Update();
  return spList;
}
票数 1
EN

Stack Overflow用户

发布于 2011-09-02 21:53:24

在部署解决方案时,VS会提示用户是否要覆盖现有的列表实例。为了防止列表被覆盖(以及所有提示),可以将"Deployment Conflict Resolution“更改为"None”。“部署冲突解决方案”可以在列表实例元素的属性窗口中找到。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7272119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档