Class CachedTypeParser
- Namespace
- Rinku
- Assembly
- Rinku.dll
Holds one result schema and caches a parser for every result type requested over it. A parameterless instance learns the schema from its first query. The instance can be shared across threads.
public sealed class CachedTypeParser : IDisposable
- Inheritance
-
CachedTypeParser
- Implements
- Inherited Members
- Extension Methods
Constructors
CachedTypeParser()
Creates a cache that learns its result columns from the first query.
public CachedTypeParser()
CachedTypeParser(ColumnInfo[])
Creates a cache for the supplied result columns.
public CachedTypeParser(ColumnInfo[] schema)
Parameters
schemaColumnInfo[]
CachedTypeParser(Delegate)
Creates a cache for columns derived from a delegate's parameters.
public CachedTypeParser(Delegate schemaFactory)
Parameters
schemaFactoryDelegate
CachedTypeParser(ConstructorInfo)
Creates a cache for columns derived from a constructor's parameters.
public CachedTypeParser(ConstructorInfo schemaConstructor)
Parameters
schemaConstructorConstructorInfo
CachedTypeParser(MethodBase)
Creates a cache for columns derived from a method's parameters.
public CachedTypeParser(MethodBase schemaMethod)
Parameters
schemaMethodMethodBase
CachedTypeParser(Type)
Creates a cache for columns derived from schemaType.
public CachedTypeParser(Type schemaType)
Parameters
schemaTypeType
Properties
HasSchema
Whether this instance already knows its fixed result columns.
public bool HasSchema { get; }
Property Value
Schema
The fixed columns every parser from this cache accepts.
public ColumnInfo[] Schema { get; }
Property Value
Exceptions
- InvalidOperationException
The parameterless instance has not run a query yet.
Methods
Dispose()
Releases every parser held by this instance and stops it from receiving invalidation notices.
public void Dispose()
From<TSchema>()
Creates a cache for the columns derived from TSchema.
public static CachedTypeParser From<TSchema>()
Returns
Type Parameters
TSchema
Get(Type, INullColHandler?)
Gets the parser for a runtime result type over this cache's fixed schema.
public ITypeParser Get(Type type, INullColHandler? nullColHandler = null)
Parameters
typeTypenullColHandlerINullColHandler
Returns
Get<T>(INullColHandler?)
Gets the parser for T over this cache's fixed schema.
public ITypeParser<T> Get<T>(INullColHandler? nullColHandler = null)
Parameters
nullColHandlerINullColHandler
Returns
- ITypeParser<T>
Type Parameters
T
Invalidate()
Forgets every parser held by this cache.
public int Invalidate()
Returns
- int
The number of distinct parsers removed.
Invalidate<T>(INullColHandler?)
Forgets the parser for T held by this cache.
public bool Invalidate<T>(INullColHandler? nullColHandler = null)
Parameters
nullColHandlerINullColHandler
Returns
Type Parameters
T
Query(Type, DbCommand, bool)
Queries cmd while mapping the result to a runtime type.
public object? Query(Type type, DbCommand cmd, bool disposeCommand = false)
Parameters
Returns
Query(Type, IDbCommand, bool)
Queries cmd while mapping the result to a runtime type.
public object? Query(Type type, IDbCommand cmd, bool disposeCommand = false)
Parameters
typeTypecmdIDbCommanddisposeCommandbool
Returns
QueryAsync(Type, DbCommand, bool, CancellationToken)
Asynchronously queries cmd while mapping the result to a runtime type.
public Task<object?> QueryAsync(Type type, DbCommand cmd, bool disposeCommand = false, CancellationToken ct = default)
Parameters
typeTypecmdDbCommanddisposeCommandboolctCancellationToken
Returns
QueryAsync(Type, IDbCommand, bool, CancellationToken)
Asynchronously queries cmd while mapping the result to a runtime type.
public Task<object?> QueryAsync(Type type, IDbCommand cmd, bool disposeCommand = false, CancellationToken ct = default)
Parameters
typeTypecmdIDbCommanddisposeCommandboolctCancellationToken
Returns
QueryAsync<T>(DbCommand, ICache, bool, CancellationToken)
Asynchronously queries cmd while updating cache.
public Task<T> QueryAsync<T>(DbCommand cmd, ICache cache, bool disposeCommand = false, CancellationToken ct = default)
Parameters
cmdDbCommandcacheICachedisposeCommandboolctCancellationToken
Returns
- Task<T>
Type Parameters
T
QueryAsync<T>(DbCommand, bool, CancellationToken)
Asynchronously queries cmd as T and learns the fixed schema when needed.
public Task<T> QueryAsync<T>(DbCommand cmd, bool disposeCommand = false, CancellationToken ct = default)
Parameters
cmdDbCommanddisposeCommandboolctCancellationToken
Returns
- Task<T>
Type Parameters
T
QueryAsync<T>(IDbCommand, ICache, bool, CancellationToken)
Asynchronously queries cmd while updating cache.
public Task<T> QueryAsync<T>(IDbCommand cmd, ICache cache, bool disposeCommand = false, CancellationToken ct = default)
Parameters
cmdIDbCommandcacheICachedisposeCommandboolctCancellationToken
Returns
- Task<T>
Type Parameters
T
QueryAsync<T>(IDbCommand, bool, CancellationToken)
Asynchronously queries cmd as T and learns the fixed schema when needed.
public Task<T> QueryAsync<T>(IDbCommand cmd, bool disposeCommand = false, CancellationToken ct = default)
Parameters
cmdIDbCommanddisposeCommandboolctCancellationToken
Returns
- Task<T>
Type Parameters
T
Query<T>(DbCommand, ICache, bool)
Queries cmd while updating cache.
public T Query<T>(DbCommand cmd, ICache cache, bool disposeCommand = false)
Parameters
Returns
- T
Type Parameters
T
Query<T>(DbCommand, bool)
Queries cmd as T and learns the fixed schema when needed.
public T Query<T>(DbCommand cmd, bool disposeCommand = false)
Parameters
Returns
- T
Type Parameters
T
Query<T>(IDbCommand, ICache, bool)
Queries cmd while updating cache.
public T Query<T>(IDbCommand cmd, ICache cache, bool disposeCommand = false)
Parameters
cmdIDbCommandcacheICachedisposeCommandbool
Returns
- T
Type Parameters
T
Query<T>(IDbCommand, bool)
Queries cmd as T and learns the fixed schema when needed.
public T Query<T>(IDbCommand cmd, bool disposeCommand = false)
Parameters
cmdIDbCommanddisposeCommandbool
Returns
- T
Type Parameters
T
StreamQueryAsync<T>(DbCommand, bool, CancellationToken)
Streams rows from cmd as T over this cache's fixed schema.
public IAsyncEnumerable<T> StreamQueryAsync<T>(DbCommand cmd, bool disposeCommand = false, CancellationToken ct = default)
Parameters
cmdDbCommanddisposeCommandboolctCancellationToken
Returns
Type Parameters
T