Class BaseSqlReader
- Namespace
- Dynamicweb.DataIntegration.Integration
- Assembly
- Dynamicweb.DataIntegration.dll
Reads rows from a SQL-backed source mapping and supports immediate response write-back updates.
public abstract class BaseSqlReader : ISourceReader, IDisposable, IResponseWriter
- Inheritance
-
BaseSqlReader
- Implements
- Derived
- Inherited Members
Constructors
BaseSqlReader()
protected BaseSqlReader()
BaseSqlReader(Mapping, SqlConnection)
public BaseSqlReader(Mapping mapping, SqlConnection connection)
Parameters
mappingMappingconnectionSqlConnection
Fields
_command
protected SqlCommand? _command
Field Value
_reader
protected SqlDataReader? _reader
Field Value
mapping
protected Mapping mapping
Field Value
Properties
PkColumnsForResponseMapping
protected IEnumerable<string> PkColumnsForResponseMapping { get; }
Property Value
Methods
Close()
Closes and disposes the response write-back command and connection.
public void Close()
Dispose()
Disposes the active SQL reader and releases the response write-back resources.
public void Dispose()
GetColumns()
protected virtual string GetColumns()
Returns
GetColumnsFromMappingConditions()
protected string GetColumnsFromMappingConditions()
Returns
GetColumnsFromMappingConditions(string[])
protected string GetColumnsFromMappingConditions(string[] columnsToSkip)
Parameters
columnsToSkipstring[]
Returns
GetDistinctColumnsFromMapping()
protected string GetDistinctColumnsFromMapping()
Returns
GetDistinctColumnsFromMapping(string[])
protected string GetDistinctColumnsFromMapping(string[] columnsToSkip)
Parameters
columnsToSkipstring[]
Returns
GetFromTables()
protected virtual string GetFromTables()
Returns
GetNext()
Returns the current row from the active SQL reader.
public virtual Dictionary<string, object> GetNext()
Returns
- Dictionary<string, object>
The current reader row, or an empty dictionary when no SQL reader has been initialized.
GetPrimaryKeyColumns(bool)
protected IEnumerable<string> GetPrimaryKeyColumns(bool returnOnlyMissedInMappings = true)
Parameters
returnOnlyMissedInMappingsbool
Returns
HandleResponseCommands(IReadOnlyCollection<KeyValuePair<string, Dictionary<string, object?>>>)
Handles response write-back commands either immediately on a dedicated connection or later during Close().
protected virtual void HandleResponseCommands(IReadOnlyCollection<KeyValuePair<string, Dictionary<string, object?>>> responseSqls)
Parameters
responseSqlsIReadOnlyCollection<KeyValuePair<string, Dictionary<string, object>>>The parameterized SQL update commands to execute for the current response rows.
IsDone()
Determines whether the active SQL reader has reached the end of the result set.
public virtual bool IsDone()
Returns
- bool
truewhen no more rows are available; otherwisefalse.
SetReaderMapping(Mapping)
Applies the mapping used by the reader and refreshes response-mapping metadata derived from it.
protected void SetReaderMapping(Mapping targetMapping)
Parameters
targetMappingMappingThe mapping that should drive source reads and response write-back behavior.
Write(Dictionary<string, object>)
Writes response-mapped values back to the source table for the current row.
public void Write(Dictionary<string, object> row)
Parameters
rowDictionary<string, object>The response row containing the destination values that should be written back.
Exceptions
- InvalidOperationException
Thrown when response mappings depend on key values that are missing from
row, or when fallback key resolution requires an active reader that is not available.