代码段:枚举客户端缓存中的外部内容类型
上次修改时间: 2010年5月7日
适用范围: SharePoint Server 2010
本文内容
说明
先决条件
使用此示例
说明
以下代码示例演示如何访问客户端缓存,以及如何枚举缓存中的外部内容类型。
先决条件
Microsoft Office 2010 和 Microsoft .NET Framework 3.5 位于客户端计算机上。
Microsoft Visual Studio。
至少在 BCS 客户端缓存中部署了一个解决方案。
使用此示例
在客户端计算机上启动 Visual Studio,然后创建一个 C# Office 应用程序加载项项目。创建项目时选择".NET Framework 3.5"。
从"视图"菜单中,单击"属性页"以显示项目属性。
在"生成"选项卡中,为"目标平台"选择"任何 CPU"。
关闭项目属性窗口。
在"解决方案资源管理器"中的"引用"下,删除除 System 和 System.Core 之外的所有项目引用。
向项目中添加以下引用:
Microsoft.Office.BusinessApplications.Runtime
Microsoft.BusinessData
使用以下语句来替换现有的 using 语句。
using System; using Microsoft.BusinessData.MetadataModel; using Microsoft.Office.BusinessData.MetadataModel; using System.Windows.Forms;
使用在此过程的结尾列出的代码替换加载项的启动事件中的代码。
使用有效值来替换 solutionId、entityNameSpace、entityName 和 lsiName 的值。
保存该项目。
编译并运行该项目。
RemoteSharedFileBackedMetadataCatalog RemoteCatalog = new RemoteSharedFileBackedMetadataCatalog();
foreach (IEntity entity in RemoteCatalog.GetEntities("*"))
{
MessageBox.Show(entity.Name);
}