BCS Meta Man – Adding and Removing Methods

Why

Adding new methods allows you to add methods which you may not have chosen when you first created your External Content Type and also gives you the ability to create Views of your data.

What are we going to do?

We are going to add a new Finder method to allow us to use it as an extra ‘View’ on our External System data, we are going to remove the existing Specific Finder and IDEnumerator Methods. We will also change the Display name for one of our Fields to make it more user friendly.

Prerequisites

  • SharePoint Server 2010
  • Visual Studio 2010 Professional or higher
  • BCS Meta Man
  • AdventureWorks SQL Database
  • Follow the ‘BCS Meta Man – Getting Started’ Tutorial to create your External Content Type, but don’t deploy yet.

Walkthrough

  1. If you have followed the ‘BCS Meta Man – Getting Started’ Tutorial you should have a ‘Product’ External Content Type on your Diagram which looks like the following

    External Content Type on your design surface

  2. To edit the Product External Content Type, Right-Click on it and select ‘Manage Entity’

    Right click the External Content Type and choose Manage Entity

  3. When the ‘Manage Entity Dialog’ pops up, switch to the Methods Tab

    Switch to the Methods tab

  4. If you click on each of the methods you will be able to see what Fields they are returning
  5. First of all we will remove the two methods which we are not interested in, select the Specific Finder Method (GetSingleProductEntityByID) and click on the ‘Remove Method’ button, repeat the same for the IDEnumerator method (GetAllProductEntitysIDs)
  6. We should now just have our Default Finder Method

    Remove the other methods just leaving our Finder

  7. Click on the ‘Add Method’ button
  8. Make sure you select the ‘Finder’ Method Type and give the new Method a name, such as ‘GetNameAndCostForAllProductEntitys’, click ‘Create’

    Add a new Finder method 

    In this dialog you can create Methods for the following methods types:

    • Finder – Return all data from External System
    • Specific Finder – Return one row of data from External System
    • IDEnumerator – Return just the Identifiers for each row in External System
    • Updater – Update row of data in External System
    • Creator – Add new row of data to External System
  9. Highlight your new method and click the ‘Set As Default’ button to set it as the default Finder method for the External Content Type, by setting this as default it will be the method used to retrieve the data in the Business Data List, the other Finder Method will appear as an alternative View in the Tool pane.

    Set new Finder method as the Default

  10. Next we want remove all of the Fields returned apart from the ‘’Name’ and ‘ListPrice’, we need to keep the ‘ProductID’ as it is the Identifier for our External Content Type rows, to remove the other Fields just highlight them and click on the ‘Remove Field’ button. When finished it should look like this

    Modify which fields the method returns

    If you accidentally remove the wrong Field, you can just click on the ‘Add Field’ button, select the correct Field and re-add it

  11. Select the ‘ListPrice’ Field and then in the ‘Display Name’ box, change its value to ‘Cost’

    Set the Display Name of a field

  12. Our configuration is done, Click the ‘Update’ button, this will update the Model and also generate the C# code for the new method.
  13. Once the Update process has finished you will see the External Content Type has updated to reflect our changes

    External Content Type reflects the modifications

  14. Press F5 to deploy
  15. Add a new Business Data List Web Part to your SharePoint page
  16. Click on the ‘Open the tool pane’ link
  17. Click on the icon to show the available External Content Types

    Open the External Content Type picker 

  18. Select our BCSMetaManDemo.ProductsModel.Product External Content Type, click OK

    Select the Product External Content Type

  19. Click ‘OK’ on the tool pane
  20. Your External System data is now displayed in the SharePoint Web Part

    External Data is now displayed in the External List Web Part

    You should notice that we have are bringing back the default method with just the Identifer, Product and the ListPrice which is displayed as Cost

  21. If you want to change the View you can do so in the Toolpane to switch to the original method where all Fields are returned.