ManagedProperty.Delete メソッド (Microsoft.Office.Server.Search.Administration)
検索スキーマから管理プロパティを削除します。
名前空間: Microsoft.Office.Server.Search.Administration
アセンブリ: Microsoft.Office.Server.Search (microsoft.office.server.search.dll 内)
構文
'宣言
Public Sub Delete
'使用
Dim instance As ManagedProperty
instance.Delete
public void Delete ()
備考
マッピングがない管理オブジェクトのみが Delete メソッドを呼び出すことができます。管理プロパティにマップされているクロールされたプロパティがまだ存在する場合は、このメソッドでエラーが発生します。
このエラーが発生しないようにするには、Delete メソッドを呼び出す前に DeleteAllMappings メソッドを呼び出します。
また、 DeleteDisallowed プロパティの値をチェックして、管理プロパティが削除できることを確認する必要があります。このプロパティが true である場合は、検索スキーマから管理プロパティを削除できません。
例
以下のコード例は、検索スキーマから管理プロパティを削除します。コードの完全なサンプルと説明に関しては、「[方法] 管理プロパティを削除する」を参照してください。
Prerequisites
共有サービス プロバイダが既に作成されていることを確認します。
Project References
このサンプルを実行する前に、コンソール アプリケーション コード プロジェクトに以下のプロジェクト参照を追加します。
Microsoft.SharePoint
Microsoft.Office.Server
Microsoft.Office.Server.Search
using System;
using System.Collections;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;
namespace DeleteManagedPropertiesSample
{
class Program
{
static void Main(string[] args)
{
try
{
//Replace <ManagedPropertyName> with the name of the property to delete.
string strName = "<ManagedPropertyName>";
//Replace <SiteName> with the name of a site using the Shared Service Provider.
string strURL = "http://<SiteName>";
Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
ManagedPropertyCollection properties = sspSchema.AllManagedProperties;
foreach (ManagedProperty property in properties)
{
if (property.Name == strName)
{
if (property.DeleteDisallowed)
{
Console.WriteLine("DeleteDisallowed enabled for " + strName + ". Delete failed.");
return;
}
property.DeleteAllMappings();
property.Delete();
Console.WriteLine(strName + " deleted.");
return;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
関連項目
参照
ManagedProperty クラス
ManagedProperty メンバ
Microsoft.Office.Server.Search.Administration 名前空間