Contains

This method verifies whether a role is present in the roles collection or a role is enabled on a connection if the connection is open depending on the Oracle software versions.

Declaration

// C#
public bool Contains(string Role)

Parameters

Role - Role name to check for presence in the roles collection.

Return Value

A Boolean value indicating if the role is present in the ODP.NET roles collection or that role is enabled in the current session. The exact behavior depends on the database version.

Exceptions

ArgumentNullException - It is thrown when role name is provided as Null.

ArgumentException - It is thrown when role name is provided as empty string.

ArgumentException - It is thrown when case sensitive role name is not enclosed properly within double quotes.

Remarks

For Oracle Database 23ai, 23.8 and earlier versions, this method only checks for roles specified in the OracleConnection.Roles property regardless whether the connection is open or closed.

For Oracle Database and ODP.NET versions 23.9 and later, this method checks if a given role is enabled on the current session, which requires the connection to be open. This method still returns true for roles not specified using OracleRoleCollection.Add but still are enabled on the current session. An example are default roles, which are enabled on the session as soon as it establishes.

For DRCP connections, until a session attaches to the OracleConnection object, this method searches the role name specified in the OracleRoleCollection object.