The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Add a Filter Descriptor to a Finder Method

Filter descriptors enable consumers of the model to pass values to methods before they execute. For more information, see Designing a Business Data Connectivity Model.

One common scenario is that users in SharePoint want to retrieve instances of an external content type that match some criteria. You can support this scenario by adding a filter descriptor to a Finder method.

To add a filter descriptor to a Finder method

  1. In the BDC Method Details window, expand the node of a Finder method, expand the Parameters node, and then add an input parameter. For more information, see How to: Add a Parameter to a Method.

  2. In the Method Details window, choose the type descriptor of the parameter.

  3. On the menu bar, choose View, Properties Window.

  4. In the Properties window, set the Type Name property to a data type that is appropriate for the filter.

    For example, a filter might use an order date to limit the number of sales orders returned by the method. To support that filter, the Type Name property of the type descriptor must be set to System.DateTime.

  5. In the Method Details window, expand the Filter Descriptors node.

  6. In Add a Filter Descriptor list, choose Create Filter Descriptor.

    A new filter descriptor appears underneath the Filter Descriptors node.

  7. On the menu bar, choose View, Properties Window.

  8. In the Properties window, choose the Type property.

  9. In the list that appears for the Type property, choose the filtering pattern that you want.

    For example, to create a filter that uses an order date to limit the number of sales orders returned in a Finder method, choose Comparison. A Comparison filter ensures that a finder method returns only instances that meet a specific condition. For more information about each filtering pattern, see Types of Filters Supported by the BDC.

  10. In the Properties window, choose the Associated Type Descriptors property.

  11. In the list that appears for the Associated Type Descriptors property, choose the type descriptor that you created earlier in this procedure. This relates the filter to the input parameter of the Finder method.

  12. Add code to the Finder method that returns data. You can use the input parameter as a condition in a select query.

    The following example returns sales orders that have the specified order date.

    Note Note

    Replace the value of the ServerName field with the name of your server.

    public static IEnumerable<SalesOrderHeader> ReadList(DateTime OrderDateParam)
        const string ServerName = "MySQLServerName";
        AdventureWorksDataContext dataContext = new AdventureWorksDataContext
              ("Data Source=" + ServerName + ";" +
               "Initial Catalog=AdventureWorks;Integrated Security=True");
        DateTime NoValuePassedIn = Convert.ToDateTime("1/1/1900 12:00:00 AM");
        DateTime DefaultDateTime = Convert.ToDateTime("2001-09-01 00:00:00.000");
        // If the user does not provide a value for the filter. 
        if (OrderDateParam == NoValuePassedIn)
            // Use a default date time value.
            OrderDateParam = DefaultDateTime;
        IEnumerable<SalesOrderHeader> SalesOrderHeader =
            from salesOrderHeaders in dataContext.SalesOrderHeaders
            where salesOrderHeaders.OrderDate == OrderDateParam
            select salesOrderHeaders;
        return SalesOrderHeader;
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft