private static void BindBlob(Sqlite3StmtHandle stmt, int index, byte[] value) =>
 NativeMethods.sqlite3_bind_blob(stmt, index, value, value.Length, Constants.SQLITE_TRANSIENT);
 private static void BindText(Sqlite3StmtHandle stmt, int index, string value) =>
 NativeMethods.sqlite3_bind_text(stmt, index, value, Constants.SQLITE_TRANSIENT);
        internal bool Bind(Sqlite3StmtHandle stmt)
        {
            if (_parameterName.Length == 0)
            {
                throw new InvalidOperationException(Strings.FormatRequiresSet("ParameterName"));
            }

            var index = NativeMethods.sqlite3_bind_parameter_index(stmt, _parameterName);

            if (index == 0)
            {
                return(false);
            }

            if (_value == null)
            {
                throw new InvalidOperationException(Strings.FormatRequiresSet("Value"));
            }

            if (!_bindActionValid)
            {
                var type = Value.GetType().UnwrapNullableType().UnwrapEnumType();
                if (type == typeof(bool))
                {
                    var value = (bool)_value ? 1L : 0;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(byte))
                {
                    var value = (long)(byte)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(byte[]))
                {
                    var value = (byte[])_value;
                    _bindAction = (s, i) => BindBlob(s, i, value);
                }
                else if (type == typeof(char))
                {
                    var value = (long)(char)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(DateTime))
                {
                    var value = ((DateTime)_value).ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFF");
                    _bindAction = (s, i) => BindText(s, i, value);
                }
                else if (type == typeof(DateTimeOffset))
                {
                    var value = ((DateTimeOffset)_value).ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFFzzz");
                    _bindAction = (s, i) => BindText(s, i, value);
                }
                else if (type == typeof(DBNull))
                {
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_null(s, i);
                }
                else if (type == typeof(decimal))
                {
                    var value = ((decimal)_value).ToString(CultureInfo.InvariantCulture);
                    _bindAction = (s, i) => BindText(s, i, value);
                }
                else if (type == typeof(double))
                {
                    var value = (double)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_double(s, i, value);
                }
                else if (type == typeof(float))
                {
                    var value = (double)(float)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_double(s, i, value);
                }
                else if (type == typeof(Guid))
                {
                    var value = ((Guid)_value).ToByteArray();
                    _bindAction = (s, i) => BindBlob(s, i, value);
                }
                else if (type == typeof(int))
                {
                    var value = (long)(int)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(long))
                {
                    var value = (long)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(sbyte))
                {
                    var value = (long)(sbyte)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(short))
                {
                    var value = (long)(short)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(string))
                {
                    var value = (string)_value;
                    _bindAction = (s, i) => BindText(s, i, value);
                }
                else if (type == typeof(TimeSpan))
                {
                    var value = ((TimeSpan)_value).ToString("c");
                    _bindAction = (s, i) => BindText(s, i, value);
                }
                else if (type == typeof(uint))
                {
                    var value = (long)(uint)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(ulong))
                {
                    var value = (long)(ulong)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else if (type == typeof(ushort))
                {
                    var value = (long)(ushort)_value;
                    _bindAction = (s, i) => NativeMethods.sqlite3_bind_int64(s, i, value);
                }
                else
                {
                    throw new InvalidOperationException(Strings.FormatUnknownDataType(type));
                }

                _bindActionValid = true;
            }

            _bindAction(stmt, index);

            return(true);
        }