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.
- 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.
- 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
- To edit the Product External Content Type, Right-Click on it and select ‘Manage Entity’
- When the ‘Manage Entity Dialog’ pops up, switch to the Methods Tab
- If you click on each of the methods you will be able to see what Fields they are returning
- 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)
- We should now just have our Default Finder Method
- Click on the ‘Add Method’ button
- Make sure you select the ‘Finder’ Method Type and give the new Method a name, such as ‘GetNameAndCostForAllProductEntitys’, click ‘Create’
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
- 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.
- 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
If you accidentally remove the wrong Field, you can just click on the ‘Add Field’ button, select the correct Field and re-add it
- Select the ‘ListPrice’ Field and then in the ‘Display Name’ box, change its value to ‘Cost’
- Our configuration is done, Click the ‘Update’ button, this will update the Model and also generate the C# code for the new method.
- Once the Update process has finished you will see the External Content Type has updated to reflect our changes
- Press F5 to deploy
- Add a new Business Data List Web Part to your SharePoint page
- Click on the ‘Open the tool pane’ link
- Click on the icon to show the available External Content Types
- Select our BCSMetaManDemo.ProductsModel.Product External Content Type, click OK
- Click ‘OK’ on the tool pane
- Your External System data is now displayed in the SharePoint 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
- 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.