예제 #1
0
        /// <summary>
        /// Bind the parameter to an <see cref="ISQLiteValue"/>.
        /// </summary>
        /// <param name="This">The bind parameter.</param>
        /// <param name="value">A <see cref="ISQLiteValue"/>.</param>
        public static void Bind(this IBindParameter This, ISQLiteValue value)
        {
            Contract.Requires(This != null);
            Contract.Requires(value != null);

            switch (value.SQLiteType)
            {
            case SQLiteType.Blob:
                if (value is ZeroBlob)
                {
                    This.BindZeroBlob(value.Length);
                }
                else
                {
                    This.Bind(value.ToBlob());
                }
                return;

            case SQLiteType.Null:
                This.BindNull();
                return;

            case SQLiteType.Text:
                This.Bind(value.ToString());
                return;

            case SQLiteType.Float:
                This.Bind(value.ToDouble());
                return;

            case SQLiteType.Integer:
                This.Bind(value.ToInt64());
                return;
            }
        }
예제 #2
0
        /// <summary>
        /// Bind the parameter to an <see cref="Stream"/>.
        /// </summary>
        /// <param name="This">The bind parameter.</param>
        /// <param name="value">A <see cref="Stream"/>.</param>
        public static void Bind(this IBindParameter This, Stream value)
        {
            Contract.Requires(This != null);
            Contract.Requires(value != null);

            if (!value.CanRead)
            {
                ThrowHelper.ThrowArgumentException("Stream is not readable");
            }

            // FIXME: Stream.Length is Int64, better to take max int
            This.BindZeroBlob((int)value.Length);
        }