Compartir a través de


: WildcardFilter (Clase) (Microsoft.Office.Server.ApplicationRegistry.Runtime)

Represents a filter that limits the instances returned to those where field like value, where value may contain the asterisk (*) wildcard character.

Espacio de nombres:
Ensamblado: Microsoft.SharePoint.Portal (in microsoft.sharepoint.portal.dll)

Sintaxis

'Declaración
<SerializableAttribute> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel:=True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel:=True)> _
Public Class WildcardFilter
    Inherits ComparisonFilter
'Uso
Dim instance As WildcardFilter
[SerializableAttribute] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
public class WildcardFilter : ComparisonFilter

Comentarios

Users can use this filter type to present more user-friendly filters such as "starts with" and "contains". It also insulates the user from having to know what wildcard character the particular backend uses, and how to escape the wildcard itself for a particular backend. For example, SAP uses '*' as the wildcard, and to escape it, the sequence [*]. SQL uses '%' as the wildcard. It does this by providing a single '*' wildcard char and a single \* escape sequence that one would use to actually pass a literal * as input. Metadata authors set the WildcardCharacterEscapeFormat and WildcardCharacter properties on the LobSystem to map these to system specific wildcard requirements.

Ejemplo

This example shows how to execute a WildcardFinder method on the Product entity in the AdventureWorksSample2000 sample. The example limits the Entity instances returned to those in the AdventureWorks 2000 sample that contain the word bike in the product name.

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 that are 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 ExecuteWildcardFilter
    {
        const string yourSSPName ="EnterYourSSPNameHere";

        static void Main(string[] args)
        {
            SetupBDC();
            FindFiltered();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }
        static void FindFiltered()
        {
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
            Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
            FilterCollection fc = prodEntity.GetFinderFilters();
            FilterCollection newfc = new FilterCollection();
            for (int i = 0; i < fc.Count; i++)
            {
                if (fc[i].GetType().FullName == "Microsoft.Office.Server.ApplicationRegistry.Runtime.WildcardFilter")
                {
                    if (string.IsNullOrEmpty("Name") || (0 == string.Compare(fc[i].Name, "Name")))
                    {
                        newfc.Add(fc[i]);
                    }
                }
            }
            ((WildcardFilter)newfc[0]).Value = "*bike*";
            IEntityInstanceEnumerator prodEntityInstanceEnumerator = prodEntity.FindFiltered(newfc, AdvWorksIns);
            while (prodEntityInstanceEnumerator.MoveNext())
            {
                IEntityInstance IE = prodEntityInstanceEnumerator.Current;
                foreach (Field f in prodEntity.GetFinderView().Fields)
                    Console.Write(IE[f]);
                Console.WriteLine("");
            }
        }
    }
} 

Jerarquía de herencia

System.Object
   Microsoft.Office.Server.ApplicationRegistry.Runtime.FilterBase
     Microsoft.Office.Server.ApplicationRegistry.Runtime.UserInputFilter
       Microsoft.Office.Server.ApplicationRegistry.Runtime.ComparisonFilter
        Microsoft.Office.Server.ApplicationRegistry.Runtime.WildcardFilter

Seguridad de subprocesos

Todos los miembros estáticos públicos (compartidos en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancia sean seguros para los subprocesos.

Vea también

Referencia

WildcardFilter (Miembros)
Microsoft.Office.Server.ApplicationRegistry.Runtime (Espacio de nombres)