On this page
This topic describes Snowflake-specific behavior and provider limitations to consider when developing applications with dotConnect for Snowflake. It provides guidance and workarounds for SQL execution, transactions, data handling, session management, and Entity Framework Core integration.
SQL Execution
- Execute each SQL statement using a separate command. dotConnect for Snowflake executes one statement per command: a command text with several statements fails with the "Actual statement count 2 did not match the desired statement count 1" error. For more information, see Execution of DML Statements.
- To execute a stored procedure, use the CALL statement with CommandType set to Text. The CommandType.StoredProcedure command type isn't supported and throws a NotSupportedException. For more information, see Using Stored Procedures and Functions.
- To get the result of a stored procedure, use ExecuteScalar or ExecuteReader. dotConnect for Snowflake doesn't support output parameters: setting the Direction property of a parameter to Output, InputOutput, or ReturnValue throws NotSupportedException.
- To pass values to Snowflake Scripting code, create a stored procedure and call it with CALL. Snowflake doesn't accept parameters inside Snowflake Scripting blocks or in the arguments of a procedure called in the FROM clause.
- Use INSERT ... SELECT to insert values built by functions such as PARSE_JSON or TO_GEOGRAPHY. Snowflake doesn't support these expressions in the VALUES clause. For more information, see Write Semi-Structured Values.
- Snowflake doesn't support the RETURNING clause.
- dotConnect for Snowflake processes query results in the JSON format. Don't change the DOTNET_QUERY_RESULT_FORMAT session parameter.
Transactions
- Use the ReadCommitted or Unspecified isolation level when starting a transaction. Snowflake supports only the READ COMMITTED isolation level, and BeginTransaction throws a NotSupportedException for other levels.
- Commit or roll back the active transaction before starting a new one. A connection can have only one active transaction at a time: Snowflake doesn't support nested transactions and savepoints.
- Include only one SnowflakeConnection in a TransactionScope. Snowflake doesn't support distributed transactions.
- Execute DDL statements outside transactions. In Snowflake, DDL statements, such as CREATE TABLE and ALTER TABLE, implicitly commit the active transaction.
- Keep transactions short. If the Snowflake session ends during an active transaction, the transaction is lost, and the provider doesn't retry requests that fail because of network errors during an active transaction. For more information, see Troubleshooting.
For more information about transactions, see Modifying Data Overview.
Updating and Loading Data
- To insert or update large amounts of data, use bulk data loaders. dotConnect for Snowflake doesn't support batch updates yet, so keep the UpdateBatchSize property of a data adapter set to 1. The internal loader requires the OWNERSHIP privilege on the target table. For more information, see Bulk Data Loading.
- To update data with a command builder, use tables with a declared primary key. For a table without a primary key, the command builder identifies rows by a column that may be not unique, so an update or a deletion can change several rows. For such tables, define your own UpdateCommand and DeleteCommand.
- To update VARIANT, OBJECT, or ARRAY columns through a data adapter, specify your own InsertCommand and UpdateCommand that use PARSE_JSON. The commands generated by the command builder can't write changed values of such columns. For more information, see Update Semi-Structured Data Using a Data Adapter.
For more information about data updates, see Updating Data.
Data Types
- To pass VARIANT, OBJECT, or ARRAY values, provide them as JSON text in a String parameter and convert them by using the PARSE_JSON function in the SQL statement. Parameter values are sent as text even if the parameter type is Variant, Object, or Array, and Snowflake doesn't convert text to these types in INSERT statements. For more information, see Working with Semi-Structured Data.
- To retrieve NUMBER values that don't fit the .NET type of the column, convert them to text using TO_VARCHAR. A NUMBER column with the scale 0 is read as System.Int64, and a value outside the Int64 range throws OverflowException. A NUMBER value outside the System.Decimal range throws OverflowException too, and fractional digits beyond the precision of System.Decimal are rounded.
- dotConnect for Snowflake reads empty strings and empty binary values as DBNull. When you write an empty string or an empty byte array, Snowflake stores an empty value, not NULL.
- By default, dotConnect for Snowflake converts DateTime values between local time and UTC. To change this behavior, use the UTC Dates connection string parameter. For more information, see Date and Time Values.
For more information about supported data types and their mappings, see Data Type Mapping.
Sessions and Connection Pooling
Session state stays in a pooled connection and is visible to the next code that gets the connection from the pool, including:
- Session parameters set by using ALTER SESSION.
- Session variables defined by using SET.
- The current database and schema selected by using USE.
- Temporary tables.
Reset the settings you change, or disable pooling (Pooling=false) for connections that change the session state. For more information, see Sessions and Connection Pooling.
Entity Framework Core
- Entity Framework Core sends each INSERT, UPDATE, and DELETE statement as a separate request. The MaxBatchSize option has no effect.
- Because Snowflake doesn't support the RETURNING clause, the provider can't retrieve server-generated key values after an INSERT statement. Instead, it obtains key values from sequences before inserting data.
- Some LINQ constructs aren't supported, such as correlated subqueries that use First or Take within a projection.
- Because DDL statements in Snowflake commit the active transaction, migrations are executed without a transaction. Idempotent migration scripts aren't supported.
For more information, see Entity Framework Core Support.