Skip to content

DmSession ​

Namespace: MJCZone.DapperMatic.Security

Assembly: MJCZone.DapperMatic

Summary ​

Sets values on a connection's session, for the database's own row-level security to read: on PostgreSQL with <c>set_config</c>, read by policies as <c>current_setting('app.tenant_id', true)</c>; on SQL Server with <c>sp_set_session_context</c>, read-only, read as <c>SESSION_CONTEXT(N'tenant_id')</c>; on MySQL and MariaDB as user variables, read as <c>@tenant_id</c>, which needs <c>AllowUserVariables=True</c> in the connection string (MySQL views cannot read variables; a function that returns one can).

static public

Contents ​

Methods (5)

Methods ​

SetAsync ​

Sets values on the connection's session, opening it if it is closed.

csharp
Task SetAsync(
    IDbConnection db,
    string values,
    Object}} tx,
    IDbTransaction cancellationToken)

Parameters ​

  • db (IDbConnection) - The connection.
  • values (string) - on PostgreSQL (a dotted name, as custom settings require), any name on SQL Server, a variable name on MySQL.
  • tx (Object}}) - The transaction to use, or null.
  • cancellationToken (IDbTransaction) - The cancellation token.

Returns ​

Type: Task

A task.

GetType ​

csharp
GetType()

ToString ​

csharp
ToString()

Equals ​

csharp
Equals()

GetHashCode ​

csharp
GetHashCode()