首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

SharePoint BCS 物件模型:連接外部資料來源並取得實體資料

     編輯:關於ASP.NET

前言

Business Connectivity Services (BCS) 讓 SharePoint 整合外部資料來源。本文示範使用 Visual Studio 2010 建立視覺化 WebPart,透過 BCS 物件模型連接服務並取得實體資料。

建立專案與介面

  1. 新增 Visual Web Part 專案。
  2. 設計檢視拖入 Literal 控制項,用於顯示回傳資訊。

新增 Visual Web Part 專案 設計介面加入 Literal 控制項

核心程式碼架構

using Microsoft.BusinessData.Runtime;
using Microsoft.SharePoint.WebControls;

public partial class BCSWebPartUserControl : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // 1. 取得 LobSystemInstance
        // 2. 取得 Entity
        // 3. 執行 Finder/SpecificFinder 方法
        // 4. 將結果繫結至 Literal 或其他控制項
    }
}

關鍵 BCS 物件模型類別

  • LobSystemInstance:外部系統執行個體(連線字串、驗證)。
  • Entity:實體定義(欄位、方法、關聯)。
  • MethodInstance:Finder、SpecificFinder、Updater 等操作。
  • EntityInstance:實際資料列物件。

部署與驗證

  • 封裝為 .wsp 部署至 SharePoint 菁英站台。
  • 確認 BDC 模型已正確發布且權限設定完成。
  • 將 WebPart 加入頁面,觀察 Literal 輸出實體資料。

總結

BCS 物件模型提供強型別、伺服器端的外部資料存取方式,配合 Visual WebPart 可快速建置整合外部系統的 SharePoint 元件。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved