Properties 如何检查SharePoint网站上是否存在web属性?

Properties 如何检查SharePoint网站上是否存在web属性?,properties,sharepoint-2010,web,Properties,Sharepoint 2010,Web,我需要使用客户端对象模型检查SharePoint网站上是否存在web属性 SP.Web web = clientContext.Site.RootWeb; clientContext.Load(web.AllProperties, p=> p[propertyName]); clientContext.ExecuteQuery(); 此代码失败,因为没有名为propertyName的属性。在尝试加载之前,如何检查此属性是否存在 Site spSite = clientContext.Si

我需要使用客户端对象模型检查SharePoint网站上是否存在web属性

SP.Web web = clientContext.Site.RootWeb;
clientContext.Load(web.AllProperties, p=> p[propertyName]);
clientContext.ExecuteQuery();
此代码失败,因为没有名为propertyName的属性。在尝试加载之前,如何检查此属性是否存在

Site spSite = clientContext.Site;
clientContext.Load(spSite);
Web spWeb = spSite.RootWeb;
clientContext.Load(spWeb, w => w.AllProperties);
clientContext.ExecuteQuery();
var allProperties = spWeb.AllProperties;
clientContext.Load(allProperties);

// next line checks if property exists
if (!spWeb.AllProperties.FieldValues.ContainsKey("SiteType"))
{
    spWeb.AllProperties["SiteType"] = "BuildWork";
    spWeb.Update();
}
clientContext.Load(spWeb, w => w.AllProperties);
clientContext.ExecuteQuery();