Interface IDataContext
Database connection abstraction interface.
Namespace: LinqToDB
Assembly: linq2db.dll
Syntax
public interface IDataContext : IConfigurationID, IAsyncDisposable
Properties
| Improve this Doc View SourceCloseAfterUse
Gets or sets flag to close context after query execution or leave it open.
Declaration
bool CloseAfterUse { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ContextName
Provider identifier.
Declaration
string ContextName { get; }
Property Value
Type | Description |
---|---|
System.String |
CreateSqlProvider
Gets SQL builder service factory method for current context data provider.
Declaration
Func<ISqlBuilder> CreateSqlProvider { get; }
Property Value
Type | Description |
---|---|
Func<ISqlBuilder> |
DataReaderType
Gets data reader implementation type for current context data provider.
Declaration
Type DataReaderType { get; }
Property Value
Type | Description |
---|---|
Type |
GetSqlOptimizer
Gets SQL optimizer service factory method for current context data provider.
Declaration
Func<DataOptions, ISqlOptimizer> GetSqlOptimizer { get; }
Property Value
Type | Description |
---|---|
Func<DataOptions, ISqlOptimizer> |
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.
Declaration
bool InlineParameters { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MappingSchema
Gets mapping schema, used for current context.
Declaration
MappingSchema MappingSchema { get; }
Property Value
Type | Description |
---|---|
MappingSchema |
NextQueryHints
Gets list of query hints (writable collection), that will be used only for next query, executed using current context.
Declaration
List<string> NextQueryHints { get; }
Property Value
Type | Description |
---|---|
List<System.String> |
Options
Current DataContext LINQ options
Declaration
DataOptions Options { get; }
Property Value
Type | Description |
---|---|
DataOptions |
QueryHints
Gets list of query hints (writable collection), that will be used for all queries, executed using current context.
Declaration
List<string> QueryHints { get; }
Property Value
Type | Description |
---|---|
List<System.String> |
SqlProviderFlags
Gets SQL support flags for current context data provider.
Declaration
SqlProviderFlags SqlProviderFlags { get; }
Property Value
Type | Description |
---|---|
SqlProviderFlags |
SupportedTableOptions
Gets supported table options for current context data provider.
Declaration
TableOptions SupportedTableOptions { get; }
Property Value
Type | Description |
---|---|
TableOptions |
UnwrapDataObjectInterceptor
Declaration
IUnwrapDataObjectInterceptor UnwrapDataObjectInterceptor { get; }
Property Value
Type | Description |
---|---|
IUnwrapDataObjectInterceptor |
Methods
| Improve this Doc View SourceAddInterceptor(IInterceptor)
Adds interceptor instance to context.
Declaration
void AddInterceptor(IInterceptor interceptor)
Parameters
Type | Name | Description |
---|---|---|
IInterceptor | interceptor | Interceptor. |
Clone(Boolean)
Clones current context.
Declaration
IDataContext Clone(bool forNestedQuery)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | forNestedQuery |
Returns
Type | Description |
---|---|
IDataContext | Cloned context. |
Close()
Closes context connection and disposes underlying resources.
Declaration
void Close()
CloseAsync()
Closes context connection and disposes underlying resources.
Declaration
Task CloseAsync()
Returns
Type | Description |
---|---|
Task |
GetFluentMappingBuilder()
Declaration
FluentMappingBuilder GetFluentMappingBuilder()
Returns
Type | Description |
---|---|
FluentMappingBuilder |
GetQueryRunner(Query, Int32, Expression, Nullable<Object>[], Nullable<Object>[])
Returns query runner service for current context.
Declaration
IQueryRunner GetQueryRunner(Query query, int queryNumber, Expression expression, object? [] parameters, object? [] preambles)
Parameters
Type | Name | Description |
---|---|---|
Query | query | Query batch object. |
System.Int32 | queryNumber | Index of query in query batch. |
Expression | expression | Query results mapping expression. |
System.Nullable<System.Object>[] | parameters | Query parameters. |
System.Nullable<System.Object>[] | preambles | Query preambles |
Returns
Type | Description |
---|---|
IQueryRunner | Query runner service. |
GetReaderExpression(DbDataReader, Int32, Expression, Type)
Returns column value reader expression.
Declaration
Expression GetReaderExpression(DbDataReader reader, int idx, Expression readerExpression, Type toType)
Parameters
Type | Name | Description |
---|---|---|
DbDataReader | reader | Data reader instance. |
System.Int32 | idx | Column index. |
Expression | readerExpression | Data reader accessor expression. |
Type | toType | Expected value type. |
Returns
Type | Description |
---|---|
Expression | Column read expression. |
IsDBNullAllowed(DbDataReader, Int32)
Returns true, of data reader column could contain
Declaration
bool? IsDBNullAllowed(DbDataReader reader, int idx)
Parameters
Type | Name | Description |
---|---|---|
DbDataReader | reader | Data reader instance. |
System.Int32 | idx | Column index. |
Returns
Type | Description |
---|---|
System.Nullable<System.Boolean> |
|
RemoveInterceptor(IInterceptor)
Removes interceptor instance from context.
Declaration
void RemoveInterceptor(IInterceptor interceptor)
Parameters
Type | Name | Description |
---|---|---|
IInterceptor | interceptor | Interceptor. |