Redigera

Dela via


SqlPersonalizationProvider.GetCountOfState Method

Definition

Returns a count of the number of rows in the underlying data store that exist for the specified scope parameter.

public:
 override int GetCountOfState(System::Web::UI::WebControls::WebParts::PersonalizationScope scope, System::Web::UI::WebControls::WebParts::PersonalizationStateQuery ^ query);
public override int GetCountOfState (System.Web.UI.WebControls.WebParts.PersonalizationScope scope, System.Web.UI.WebControls.WebParts.PersonalizationStateQuery query);
override this.GetCountOfState : System.Web.UI.WebControls.WebParts.PersonalizationScope * System.Web.UI.WebControls.WebParts.PersonalizationStateQuery -> int
Public Overrides Function GetCountOfState (scope As PersonalizationScope, query As PersonalizationStateQuery) As Integer

Parameters

scope
PersonalizationScope

A PersonalizationScope indicating the personalization information to be queried. This value cannot be null.

query
PersonalizationStateQuery

A PersonalizationStateQuery containing a query. This value can be null.

Returns

The number of rows in the underlying data store that exist for the specified scope parameter.

Exceptions

PathToMatch is non-null and is an empty string ("") after trimming.

-or-

The length of PathToMatch is greater than 256 characters when the value is non-null.

-or-

UsernameToMatch is non-null and is an empty string after trimming.

-or-

The length of UsernameToMatch is greater than 256 characters when the value is non-null.

The scope specified is not a valid value from the PersonalizationScope enumeration.

Remarks

This method passes query wildcard characters to the underlying data store. Support for wildcard characters is currently dependent on how each provider handles characters such as an asterisk (*), a percent symbol (%), or an underscore (_).

Normally, for SQL-compliant data stores, you can perform a wildcard search on a partial path with the wildcard character appearing at the beginning, the end, or the middle of the search string text in the PathToMatch property. For example, to find all paths that start with "~/approot", the PathToMatch property would be set to "~/approot%".

Likewise, a wildcard search on a partial user name could have the wildcard character appear at any point in the text string of the UsernameToMatch property. For example, to find all user names that start with "John", the UsernameToMatch parameter would look like "John%".

The following query constraints apply:

  • If only scope is provided, and query is null or all the properties on query return either null or default values, then all records matching the indicated scope parameter are returned.

  • If the PathToMatch property is not null, the returned records are also filtered based on paths that match the PathToMatch property value.

  • If the UsernameToMatch is not null, the returned records are also filtered based on user names that match the UsernameToMatch property value.

  • If the UserInactiveSinceDate property is not equal to MaxValue, then the returned records are also filtered to return only those records associated with inactive users. The comparison includes records where the LastActivityDate property is less than or equal to the UserInactiveSinceDate property.

Note that this method does not validate combinations of query parameters. For example, code can request a count of state records associated with inactive users in the shared scope. Because there is no concept of inactive customizations, the returned count would be zero.

Parameter combinations that have the potential to return a non-empty collection include:

Applies to