Adding filters to System.Nullable types in BCS

It took me a while to find the solution for this problem, which was eventually handed to me by Dmitry Kaloshin, so I’ll share it here:

Filters in BCS are very handy, and often necessary, for reducing the amount of items when working with External Data, such as an External Data Column based on an External Content Type.

When you’re working with an external content type that has input parameters of the .NET Type System.Nullable<System.Int32>, you may run into the same problems I had.

A sample input parameter for a Read List operation, i.e. from a WCF Service, that has the System.Nullable .NET Type, may look like this:

Initial paramtere properties

If you’d want to add a Comparison filter for this input parameter, you’d probably set it up like this:

Comparison Filter

When you click OK, you’d see an Error message in the Errors and Warning list at the bottom of the page.

Error message with Filter on System.Nullable input parameter

The error reads “The filter field data type System.Nullable<System.Int32> does not match data type System.Int32 on data source element [[Element name]]“.

It seems like SharePoint BCS is unable to cope with Nullable Int .NET data types, which would be odd, as they’ve been around in the .NET Framework since version 2.0.

The solution is to set the Filter Field property of the Filter to <<none>>. Since the Filter Configuration dialog is started from the Element properties panel, the Element to filter is still linked to this filter.

Solution: Set Filter Field to None

Press OK to close the Dialog and press Finish to close the Read List dialog.

Save your changes to the Business Data Connectivity Metadata Store, and you’re done.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>