共用方式為


Creating Advanced Code-Based Solutions Using Business Connectivity Services

Applies to: SharePoint Server 2010

In this article
Programmability and Extensibility for BCS
Types of Advanced Code-Based End-to-End Solutions That Use Business Connectivity Services
Office Add-in (pre-deployed metadata)
Office Add-in (self-contained)
Office Add-in (online only)
Outlook Add-in (self-contained)
Silverlight Application

You can extend Microsoft Business Connectivity Services (BCS) and create customized solutions in several ways. This topic provides an overview of advanced code-based solutions and shows some of the necessary steps to develop, package, and deploy the various advanced code-based solutions by using Microsoft Business Connectivity Services (BCS).

Programmability and Extensibility for BCS

Business Connectivity Services provides many native capabilities that deliver rich, end-to-end solutions. Business Connectivity Services is also a programmable platform, enabling you to further extend Business Connectivity Services to create customized solutions.

The three types of Business Connectivity Services solutions that can be created are:

  • Simple solutions that use native Business Connectivity Services capabilities

  • Intermediate declarative solutions

  • Advanced code-based solutions

For more information about the different types of solutions, see Types of Solutions You Can Create Using BCS.

This topic focuses on advanced code-based solutions, which are solutions coded by developers. They range from rich end-to-end solutions with code components running on the client and on the server, to reusable Business Connectivity Services components that can be used by power users for declarative-type solutions.

The main components that you can create are Microsoft Silverlight applications, custom server components (for example, Web Parts) and Microsoft Office add-ins. The Office add-ins can be designed to function only while online to retrieve external data from the external system or they can be designed with the ability to function both online and offline by retrieving data from the Business Connectivity Services Rich Client Cache.

An important distinguishing factor in this design is the object model that you code against to retrieve the external data.

Code-Based Reusable BCS Components

In addition to developing end-to-end Business Connectivity Services solutions, you can create reusable Business Connectivity Services components for experienced users to employ. The following are examples of such components:

  • External content types (backed by a Microsoft .NET Connectivity Assembly)

  • Custom Web Parts

  • Custom workflow activities

  • Custom code-based actions

  • Custom field types (to show non-flat data structures)

  • Custom external data parts

Types of Advanced Code-Based End-to-End Solutions That Use Business Connectivity Services

You can create client components that run on the end user's client computer, custom server components that are browser-based and that run on the server, or end-to-end solutions that span both the server and client.

For client components, you can choose to create an Microsoft Office add-in or a Silverlight application.

Table 1 shows the different client solution types and server solution types.

Table 1. BCS client solution types and server solution types

Solution Type

Data Access Mode

BCS Packaging Requirement

Object Model

Microsoft Office add-in (pre-deployed metadata)

Online or offline

Uses metadata and subscriptions that are already deployed; custom code is packaged by using Microsoft Visual Studio.

BDC

Microsoft Officeadd-in (self-contained)

Online or offline

Uses packaged metadata and subscriptions through a BCS Data Solution; custom code is packaged by using Visual Studio.

BDC

Microsoft Office add-in (online only)

Online only

Custom code is packaged by using Visual Studio.

BDC or client-side object model

Microsoft Outlook add-in (self-contained)

Online or offline

BCS Solution Package

Outlook

Silverlight application

Online only

Not applicable

Client-side object model

Custom server component

Online only

Not applicable

SharePoint List (SPList) object model

The information in Figure 1 can help you decide what kind of solution to create. After you decide the type of solution that you want to create, see the section that corresponds to the solution type for a description.

Figure 1. Flowchart for choosing the type of solution

Flowchart for choosing the type of solution

Office Add-in (pre-deployed metadata)

Description

An Office development tools in Visual Studio 2010 add-in project that uses BCS APIs to access the BCS client cache data.

Target scenarios

A Microsoft Office client application add-in that discovers and reflects upon data in the BCS client cache.

Not intended for

Scenarios that depend on specific data sets. Add-ins that use solutions that are already deployed must handle situations where the data is not present and where there are multiple and changing external lists that are deployed.

Office client

Yes: Can be used with any Office Professional Plus client application: Microsoft Excel, Microsoft PowerPoint, Microsoft Word, Microsoft Access, Microsoft SharePoint Workspace, Microsoft InfoPath, and Microsoft Outlook. If Microsoft Office Professional Plus 2010 is installed on a computer with Visio and Project installed they can also be extended.

Caching

Uses the BCS client cache with offline availability.

Object model

BDC

Packaging

Regular Office development tools in Visual Studio 2010 package for the add-in.

Details

The Office add-in solution cannot handle the life cycle of the Business Connectivity Services client cache. The metadata and subscriptions must already be deployed by an existing solution, by synchronizing from a SharePoint external list to a SharePoint Workspace on the client through the list deployment experience.

Development Steps

  1. Use an external content type to create an external list on the SharePoint server.

  2. In Visual Studio 2010, create a Microsoft .NET 3.5 Office 2010 Add-in project.

  3. Make the project available for end-user deployment, either from a network shared folder or from a local folder, or from a document library folder on the computer running SharePoint Server.

    Note

    If you are using forms-based authentication for your installation of SharePoint Server, use the ActiveX control for deployment.

End-User Steps to Deploy a Solution

  1. Navigate to the SharePoint external list for the solution.

  2. Synchronize the solution with the computer by clicking the Sync to SharePoint Workspace List ribbon button.

  3. Navigate to the published project location that contains the solution add-in, and then run the .vsto file to install the add-in.

Office Add-in (self-contained)

Description

An Office development tools in Visual Studio 2010 add-in project that uses BCS APIs to access the BCS client cache data.

Target scenarios

A Microsoft Office client application add-in for both online solutions and offline solutions. Note that Outlook solutions will typically benefit from using the Outlook (self-contained) type of solution.

Office client

Yes: Can be used with any Office Professional Plus client application: Microsoft Excel, Microsoft PowerPoint, Microsoft Word, Microsoft Access, Microsoft SharePoint Workspace, Microsoft InfoPath, and Microsoft Outlook. If Microsoft Office Professional Plus 2010 is installed on a computer that also has Visio and Project installed they can also be extended.

Caching

Uses the BCS client cache with offline availability.

Object model

BDC

Packaging

Combination of a BCS Data Solution plus an Office development tools in Visual Studio 2010 package.

Details

This type of solution consists of a regular Office development tools in Visual Studio 2010 add-in combined with a Data Solution package to populate data in the client cache.

Development Steps

  1. In Visual Studio 2010, create a .NET 3.5 Office 2010 Add-in project.

  2. Make the project available for end-user deployment, either from a network shared folder or from a local folder, or from a document library folder on the computer running SharePoint Server.

    Note

    If you are using forms-based authentication for your installation of SharePoint Server, use the ActiveX control for deployment.

  3. Create a BDC model and subscription files.

    You can use the BCS Artifact Generator Tool to generate the subscription files based on the BDC model.

  4. Use the BCS Solution Packaging Tool to create a Business Connectivity Services Data Solution based on the BDC model and subscription files.

  5. Publish the Data Solution to the same location as the Office add-in solution.

End-User Steps to Deploy a Solution

  1. Navigate to the published project location that contains the Office add-in solution, and then run the .vsto file to install the add-in.

  2. Navigate to the published project location that contains the Data Solution, and then run the .vsto file to install the add-in.

Office Add-in (online only)

Description

An Office development tools in Visual Studio 2010 add-in project that uses BCS APIs to access data directly from an external system, or that uses the client-side object model to go through the server.

Target scenarios

A Microsoft Office client application add-in that will not be used offline (for example, an application that is not used by travelling workers).

Office client

For the BDC object model approach: Can be used with any Office Professional Plus client application: Microsoft Excel, Microsoft PowerPoint, Microsoft Word, Microsoft Access, Microsoft SharePoint Workspace, Microsoft InfoPath, and Microsoft Outlook. If Microsoft Office Professional Plus 2010 is installed on a computer with Visio and Project installed they can also be extended.

For the client-side object model approach: Any Office version client application is available for use.

Caching

None. This type of solution will work only when connected and will not work offline by using the cache.

Object model

Primarily BDC to directly connect to the external system by using file-based metadata, or client-side object model if it is required (through the server).

Packaging

Regular Office development tools in Visual Studio 2010 package.

Details

You should code against the BDC object model to access data directly from the external system by using the external content type. However, you can optionally code against the client-side object model to go through the server by using an external list, in case of special circumstances that require you to do so (for example, if a corporate firewall is blocking direct access to the external system).

Development Steps

  1. In Visual Studio 2010, create a .NET 3.5 Office 2010 Add-In project.

  2. For the BDC object model approach, use FileBackedMetadataCatalog to load the BDC model. (Similar to the way that you would use a server model.)

  3. Make the project available for end-user deployment, either from a network shared folder or from a local folder, or from a document library folder on the computer running SharePoint Server.

    Note

    If you are using forms-based authentication for your installation of SharePoint Server, use the ActiveX control for deployment.

End-User Steps to Deploy a Solution

  • Navigate to the published project location that contains the Office add-in solution, and then run the .vsto file to install the add-in.

Outlook Add-in (self-contained)

Description

An Office development tools in Visual Studio 2010 add-in project that uses a simplified version of an Outlook Integration Runtime configuration file (OIR.config) as a solution manifest, which will synchronize the BCS folder and form-region data with Outlook.

Target scenarios

Solutions based on a Microsoft Outlook 2010 Add-in that also implement custom coded features and use the BCS Rich Client Cache.

Office client

Is used with Microsoft Outlook 2010.

Caching

Cache that uses the Outlook Integration Runtime solution manifest for cache management and data management.

Object model

Outlook object model.

Packaging

Uses a BCS Solution Package, which is a Office development tools in Visual Studio 2010 package plus BCS Post-Deployment Action (PDA) and Solution Activation.

Details

For solutions in Outlook, BCS provides the Outlook Integration Runtime, an enhancement for cross-synchronization between Outlook and the BCS Rich Client Cache. This type of Outlook solution is an advancement of the Office Add-in (self-contained) solution type that uses Outlook, by using the solution manifest for cross-synchronization.

Development Steps

  1. Prepare the BDC model, subscription files, and a simplified OIR.config solution manifest file.

    You can use the BCS Artifact Generator Tool to generate the subscription files and the solution manifest file based on the BDC model.

  2. Prepare a simplified OIR.config solution manifest file.

  3. In Visual Studio 2010, create a .NET 3.5 Office Outlook 2010 Add-in project.

  4. Use the BCS Solution Packaging Tool to create a Business Connectivity Services solution package.

End-User Steps to Deploy a Solution

  • Navigate to the published project location that contains the Outlook add-in solution, and then run the .vsto file to install the add-in.

Silverlight Application

Description

A Silverlight application with code running on the client. It is accessed through the browser and has access to external data through the client-side object model.

Target scenarios

Rich Internet applications.

Office client

Not involved. The user experience is through the browser.

Caching

No use of client cache. Online-only experience is through the browser.

Object model

Client-side object model.

Packaging

No BCS-specific packaging is required.

Development Steps

  1. Develop a Microsoft Silverlight application.

  2. Code against the client-side object model to interact with external data.

End-User Steps to Deploy a Solution

  • Navigate to the site by using a browser.

    Note

    The client computer must have Microsoft Silverlight installed.

See Also

Concepts

Walkthrough: Creating an Advanced Code-Based Outlook Solution

How to: Creating Sandboxed Workflow Actions

Walkthrough: Use SharePoint Full-Trust Workflow Activities with Business Connectivity Services

Walkthrough: Using BCS Reusable Code Components in a Declarative Solution

Other Resources

Business Connectivity Services Object Model Code Snippets