/// <summary> /// Queries the database using the provided IStatement and provided bind variables. /// </summary> /// <param name="This">The statements.</param> /// <param name="values">The position indexed values to bind.</param> /// <returns>An <see cref="IEnumerable<T>"/> of rows in the result set.</returns> public static IEnumerable<IReadOnlyList<IResultSetValue>> Query( this IStatement This, params object[] values) { Contract.Requires(This != null); Contract.Requires(values != null); return new DelegatingEnumerable<IReadOnlyList<IResultSetValue>>(() => { This.Reset(); This.ClearBindings(); This.Bind(values); return This.Enumerate(); }); }
/* /// <summary> /// Bind the statement parameters to the key-value pairs in <paramref name="pairs"/>. /// </summary> /// <remarks> /// Bind parameters may be <see langword="null"/>, any numeric type, or an instance of <see cref="string"/>, /// byte[], or <see cref="Stream"/>. /// </remarks> /// <param name="This">The statement.</param> /// <param name="pairs">An enumerable of keyvalue pairs keyed by bind parameter name.</param> internal static void Bind(this IStatement This, IEnumerable<KeyValuePair<string,object>> pairs) { Contract.Requires(This != null); Contract.Requires(pairs != null); foreach (var kvp in pairs) { This.BindParameters[kvp.Key].Bind(kvp.Value); } }*/ /// <summary> /// Executes the <see cref="IStatement"/> with provided bind parameter values. /// </summary> /// <remarks>Note that this method resets and clears the existing bindings, before /// binding the new values and executing the statement.</remarks> /// <param name="This">The statements.</param> /// <param name="values">The position indexed values to bind.</param> public static void Execute(this IStatement This, params object[] values) { Contract.Requires(This != null); Contract.Requires(values != null); This.Reset(); This.ClearBindings(); This.Bind(values); This.MoveNext(); }
public static void ResetAndClearBindings(this ISQLiteStatement statement) { statement.Reset(); statement.ClearBindings(); }