Define Entity Metadata
Before we redeploy our assembly, we need to make
another important change. Even though we’ve updated the metadata to use
the WebResult object as our Entity class, we haven’t added metadata
defining the properties of the WebResult object. We need to update the
WebResult Type Descriptor with details of the fields on the object that
we want to allow clients to use.
Open up the model. In the BDC Explorer pane, navigate to the WebResult Type Descriptor defined on the ReadItem
method. Right-click the Type Descriptor node and select Add Type
Descriptor. This will add a child-type descriptor object that we can
use to declare details of a field.
Add the following type descriptors:
Name | Type Name |
---|
DateTime | System.DateTime |
Description | System.String |
DisplayUrl | System.String |
Title | System.String |
Url | System.String |
In the properties for the Url type descriptor, set the Identifier to itemUrl to declare this as the identifier for the entity.
Now
that we’ve updated the WebResult type descriptor for the ReadItem
method, we need to copy this information to the ReadList method.
Thankfully the BDC Explorer tool allows us to copy and paste
descriptors. Delete the existing WebResult descriptor from the ReadList
method, and then copy the WebResult descriptor node on the ReadItem
method.
Navigate to the WebResultList node on the ReadList method. Click to highlight it, and then paste the WebResult node.
We’re now good to redeploy our completed connectivity assembly. Choose Build | Deploy BingConnectivity.
Once the solution has been deployed, we can see in
SharePoint Designer that the fields are now available as expected. (You
might need to press F5 to refresh the view to see the changes.) We can
test our model by creating an External List from it. Follow the
procedure discussed in the section “Create an External List.”
When navigating to your new list for the first time,
you’ll notice that it’s empty. This is expected, because the ReadList
method requires a query property. So how do you set the property? In
External Lists, data source filters can be defined as part of the view.
If you modify the default ReadList view, you’ll find a Data Source
Filters section containing a text box to enter a parameter for our
Search Filter. Type a search query in the Search Filter text box and
save the view to see the results displayed in the list: