Share via


FilterCollection Class

Represents a collection of FilterDescriptor objects. A Method can have many filters that are user settable before executing the method. Calling Method.GetFilters returns a FilterCollection of available filters.

Inheritance Hierarchy

System.Object
  System.Collections.Generic.List<FilterBase>
    Microsoft.Office.Server.ApplicationRegistry.Runtime.FilterCollection

Namespace:  Microsoft.Office.Server.ApplicationRegistry.Runtime
Assembly:  Microsoft.SharePoint.Portal (in Microsoft.SharePoint.Portal.dll)

Syntax

'Declaration
<SerializableAttribute> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
Public Class FilterCollection _
    Inherits List(Of FilterBase)
'Usage
Dim instance As FilterCollection
[SerializableAttribute]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
public class FilterCollection : List<FilterBase>

Remarks

Filters are annotations on methods that capture the parameters users or the system provides to restrict the instances that returned. The metadata author 'tags' a particular 'slot' or field in an input parameter to a back-end API with the filterdescriptor and then when the user or system sets the value on the filter, that value is written into the field when the method is executed, overriding the default value for that field. A method can support zero or more filters.

Line-of-business (LOB) systems provide various filtering mechanisms. The Business Data Catalog abstracts common patterns so that it can provide users with the same filtering semantics, regardless of the data source. The Business Data Catalog supports the following filters and filtering patterns:

  • Comparison filter   Limits the instances that are returned to those where the specified condition is met.

  • Wildcard filter   Limits the instances that are returned to those where field like value, where value may contain the asterisk (*) wildcard character. Users can use this filter type to present more user-friendly filters such as :starts with" and "contains".

  • Limit filter   Limits the number of instances that are returned to n. SQL supports this with the SELECT TOP clause. By using a Limit filter, you can prevent long waits and time outs, and also prevent users from issuing bad queries that request large amounts of data.

  • UserContext filter   Limits the that are instances by the current user's context. This filter tells the Business Data Catalog to append the current Microsoft Windows user's domain\username to the method call. In Forms authentication, the Business Data Catalog appends the forms authentication user name.

  • Username filter   Limits the instances by a single sign-on (SSO) username. This filter tells the Business Data Catalog to pass the username from SSO as part of a parameter to the method call.

  • Password filter   Works with the Username filter. This filter tells the Business Data Catalog to pass the password from SSO as part of a parameter to the method call.

    Note

    The back-end method definition should support the filters. Only then can you, in a context-sensitive manner, use filters to reflect in the front-end Web server the functionality that is available in the back-end application. The metadata simply declares which filters a method supports.

  • UserProfile filter   Specified in the FilterDescriptor definition. To use this simple filter, declare a filter of the type "UserProfile" and add a System.String property with the name "UserProfilePropertyName", whose value is the name of a User Profile property. The Business Data Catalog looks up the current user's profile, reads the value of the property with this name, and plumbs that through to the back-end method that is invoked.

  • SSOTicket filter   Tells the Business Data Catalog to pass the SSO ticket from SSO as part of a parameter to the method call.

  • LastIdSeen filter   Enables chunking for IDEnumerator objects. For Web services and other non-streaming back-end applications, use the LastIdSeen filter in your IDEnumerator object, as shown in the following code example, to improve performance:

    SELECT TOP 100 Id FROM Customers WHERE Id>=@LastIdSeen
    ORDER BY Id
    

Examples

This example shows how to execute a Finder method on the Product entity in the AdventureWorks2000 sample.

Prerequisites

  • Ensure a Shared Service Provider is already created.

  • Replace the constant value EnterYourSSPNameHere in the code with the name of your Shared Resource Provider.

  • Ensure the LobSystem object and entity names referenced in the example exist in the Business Data Catalog. Use valid names.

Project References

Add the following Project References in your console application code project before running this sample:

  • Microsoft.SharePoint

  • Microsoft.SharePoint.Portal

  • Microsoft.Office.Server

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.Office.Server.ApplicationRegistry.MetadataModel;
using Microsoft.Office.Server.ApplicationRegistry.Runtime;
using Microsoft.Office.Server.ApplicationRegistry.SystemSpecific;
using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;
using WSSAdmin = Microsoft.SharePoint.Administration;
using OSSAdmin = Microsoft.Office.Server.Administration;

namespace Microsoft.SDK.SharePointServer.Samples
{
    class ExecuteFinder
    {
        const string yourSSPName ="EnterYourSSPNameHere";

        static void Main(string[] args)
        {
            SetupBDC();
            FindAll();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }

        static void FindAll()
        {
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
            Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
            FilterCollection fc = prodEntity.GetFinderFilters();
            IEntityInstanceEnumerator prodEntityInstanceEnumerator = prodEntity.FindFiltered(fc, AdvWorksIns);
            while (prodEntityInstanceEnumerator.MoveNext())
            {
                IEntityInstance IE = prodEntityInstanceEnumerator.Current;
                foreach (Field f in prodEntity.GetFinderView().Fields)
                    Console.Write(IE[f]);
                Console.WriteLine("");
            }
        }
       
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

FilterCollection Members

Microsoft.Office.Server.ApplicationRegistry.Runtime Namespace