Returns a new PimItemCollection that contains only items that pass a specified restriction.
| C# | Visual Basic |
public PimItemCollection Restrict( string restriction )
Public Function Restrict ( _ restriction As String _ ) As PimItemCollection
- restriction (String)
- String that defines which items to include in the new collection.
This must contain a Boolean expression that evaluates to TRUE or FALSE for any item.
Enclose property names between brackets.
Enclose criteria in quotes.
You can combine expressions with AND and OR.
Comparison operators are the following: <, <=, >, >=, =, or <>.
For example, the restriction string [CompanyName] = "Microsoft" returns a collection of items with Microsoft as the company.
A PimItemCollection with only the matching items.
A restriction match requires that the item include a value for the property.
For example, if you do not set the e-mail address for a contact, the contact will not be found using the restriction string [Email1Address] <> "get@smart.com", even though "no address" is a logical match for "not get@smart.com."
Restricting where Category is Business and CompanyName is Microsoft.
CopyVB.NET
CopyC#
Dim Strquery As String Dim MyItems As PimItemCollection Strquery = "[Categories] = " & ControlChars.Quote & "Business" & ControlChars.Quote Strquery = strquery & " and [CompanyName] = " & ControlChars.Quote & "Microsoft" & ControlChars.Quote MyItems = Items.Restrict(strquery)
string Strquery; PimItemCollection MyItems; Strquery = "[Categories] = \"Business\" and [CompanyName] = \"Microsoft\""; MyItems = Items.Restrict(strquery);