在CAML2010中,当使用SharePoint提供列表时,是否可以不覆盖现有的ListInstance (假设它已经存在)?或者定制代码是必要的?
编辑:这个问题对我来说并不清楚。我应该注意到,我是通过一个使用默认vs2010构建/部署过程的解决方案来部署列表实例的。使用此过程时,列表实例将在我部署时被删除并重新创建。我试图防止它每次都被重新创建。
发布于 2011-09-02 21:16:52
不能,不能用ListInstance元素覆盖现有列表。您可以更改EnableVersioning和Hidden。您还可以通过数据/行/行添加项目。但是原始的列表仍然存在。
下面是来自Microsoft.SharePoint.SPListInstanceElement的"documentation“代码:
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;
}发布于 2011-09-02 21:53:24
在部署解决方案时,VS会提示用户是否要覆盖现有的列表实例。为了防止列表被覆盖(以及所有提示),可以将"Deployment Conflict Resolution“更改为"None”。“部署冲突解决方案”可以在列表实例元素的属性窗口中找到。
https://stackoverflow.com/questions/7272119
复制相似问题