-
Hi all, My question is how to use DuckDBAppender retrieving data from a generic table of database server with a datareader, without knowing at compile time field types. Is there any example or documentation?
mytable must be created, retrieving data types from myserverdatareader and converting them to the specific DuckDB type. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can do it like this: object value = 42;
_ = value switch
{
bool val => row.AppendValue(val),
int val => row.AppendValue(val),
long val => row.AppendValue(val),
}; |
Beta Was this translation helpful? Give feedback.
-
Thanks. I suppose I need to include all .net data types, as in https://duckdb.net/docs/type-mapping.html I wonder if there is a way to not evaluate object type, in switch condition, for every row, as a table column type is always the same. |
Beta Was this translation helpful? Give feedback.
-
You can probably create a static |
Beta Was this translation helpful? Give feedback.
You can probably create a static
Dictionary<Type, Action>
and use DbDataReader.GetFieldType(Int32) Method to lookup the action for appending the value.