Skip to main content

SqlContext

Namespace: PPJ.Runtime.Sql

Assembly: PPJ.Runtime.50 (5.0.0.0)

Provides a scoped set of local and container objects for resolving SQL bind expressions.

public class SqlContext : IDisposable

Construction pushes a context onto the runtime context stack. Dispose contexts in reverse construction order.

Example:

using PPJ.Runtime.Sql;

var locals = new { CustomerId = 42 };
using (var context = new SqlContext(locals))
{
object currentLocals = SqlContext.Current.Locals;
}

Constructors

Instance member SqlContext(locals)

Initializes and pushes a context containing the supplied local and optional container objects.

NameTypeDescription
localsObjectThe object exposing local bind variables.

Instance member SqlContext(locals, container)

Initializes and pushes a context containing the supplied local and optional container objects.

NameTypeDescription
localsObjectThe object exposing local bind variables.
containerObjectThe enclosing object used for bind expression resolution.

Properties

Instance member Container

Object: Gets or sets the enclosing object used with the local variables during expression resolution.

Static member Current

SqlContext: Gets the context at the top of the runtime stack, creating an empty context when the stack is empty.

Instance member Disposed

Boolean: Gets whether this context has been disposed.

Instance member Locals

Object: Gets or sets the local variables object, resolving referenced SQL contexts when necessary.

Methods

Instance member Dispose()

Clears local variables and removes the context from the stack when it was pushed.

Calling Dispose more than once throws InvalidOperationException.