Interface IDataContext
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Database connection abstraction interface.
public interface IDataContext : IConfigurationID, IDisposable, IAsyncDisposable
- Inherited Members
- Extension Methods
Properties
CloseAfterUse
Gets or sets flag to close context after query execution or leave it open.
bool CloseAfterUse { get; set; }
Property Value
ConfigurationString
Gets initial value for database connection configuration name.
string? ConfigurationString { get; }
Property Value
ContextName
Provider identifier.
string ContextName { get; }
Property Value
CreateSqlProvider
Gets SQL builder service factory method for current context data provider.
Func<ISqlBuilder> CreateSqlProvider { get; }
Property Value
DataReaderType
Gets data reader implementation type for current context data provider.
Type DataReaderType { get; }
Property Value
GetSqlOptimizer
Gets SQL optimizer service factory method for current context data provider.
Func<DataOptions, ISqlOptimizer> GetSqlOptimizer { get; }
Property Value
InlineParameters
Gets or sets option to force inline parameter values as literals into command text. If parameter inlining not supported for specific value type, it will be used as parameter.
bool InlineParameters { get; set; }
Property Value
MappingSchema
Gets mapping schema, used for current context.
MappingSchema MappingSchema { get; }
Property Value
NextQueryHints
Gets list of query hints (writable collection), that will be used only for next query, executed using current context.
List<string> NextQueryHints { get; }
Property Value
Options
Current DataContext LINQ options
DataOptions Options { get; }
Property Value
QueryHints
Gets list of query hints (writable collection), that will be used for all queries, executed using current context.
List<string> QueryHints { get; }
Property Value
SqlProviderFlags
Gets SQL support flags for current context data provider.
SqlProviderFlags SqlProviderFlags { get; }
Property Value
SupportedTableOptions
Gets supported table options for current context data provider.
TableOptions SupportedTableOptions { get; }
Property Value
UnwrapDataObjectInterceptor
IUnwrapDataObjectInterceptor? UnwrapDataObjectInterceptor { get; }
Property Value
Methods
AddInterceptor(IInterceptor)
Adds interceptor instance to context.
void AddInterceptor(IInterceptor interceptor)
Parameters
interceptor
IInterceptorInterceptor.
Clone(bool)
Clones current context.
IDataContext Clone(bool forNestedQuery)
Parameters
forNestedQuery
bool
Returns
- IDataContext
Cloned context.
Close()
Closes context connection and disposes underlying resources.
void Close()
CloseAsync()
Closes context connection and disposes underlying resources.
Task CloseAsync()
Returns
GetQueryRunner(Query, int, Expression, object?[]?, object?[]?)
Returns query runner service for current context.
IQueryRunner GetQueryRunner(Query query, int queryNumber, Expression expression, object?[]? parameters, object?[]? preambles)
Parameters
query
QueryQuery batch object.
queryNumber
intIndex of query in query batch.
expression
ExpressionQuery results mapping expression.
parameters
object[]Query parameters.
preambles
object[]Query preambles
Returns
- IQueryRunner
Query runner service.
GetReaderExpression(DbDataReader, int, Expression, Type)
Returns column value reader expression.
Expression GetReaderExpression(DbDataReader reader, int idx, Expression readerExpression, Type toType)
Parameters
reader
DbDataReaderData reader instance.
idx
intColumn index.
readerExpression
ExpressionData reader accessor expression.
toType
TypeExpected value type.
Returns
- Expression
Column read expression.
IsDBNullAllowed(DbDataReader, int)
Returns true, of data reader column could contain DBNull value.
bool? IsDBNullAllowed(DbDataReader reader, int idx)
Parameters
reader
DbDataReaderData reader instance.
idx
intColumn index.
Returns
RemoveInterceptor(IInterceptor)
Removes interceptor instance from context.
void RemoveInterceptor(IInterceptor interceptor)
Parameters
interceptor
IInterceptorInterceptor.