/************************************************************************************
*
* Umbraco Data Layer
* MIT Licensed work
* ©2008 Ruben Verborgh
*
***********************************************************************************/
using System;
using System.Data;
using System.Xml;
using umbraco.DataLayer.Utility;
namespace umbraco.DataLayer
{
///
/// Interface of a module that interacts with a certain type of SQL database.
///
public interface ISqlHelper : IDisposable
{
///
/// Gets the connection string.
///
/// The connection string.
string ConnectionString { get; }
///
/// Gets the Umbraco utility associated with this SQL helper.
///
/// The utilities.
IUtilitySet Utility { get; }
///
/// Creates a new parameter for use with this specific implementation of ISqlHelper.
///
/// Name of the parameter.
/// Value of the parameter.
/// A new parameter of the correct type.
/// Abstract factory pattern
IParameter CreateParameter(string parameterName, object value);
///
/// Escapes a string for use in an SQL query.
///
/// The value.
/// The escaped value.
/// You should use parameters instead.
[Obsolete("You should use parameters instead. (see CreateParameter)", false)]
string EscapeString(string value);
///
/// Executes a command and returns the number of rows affected.
///
/// The command text.
/// The parameters.
/// The number of rows affected by the command.
/// If a data source error occurs.
int ExecuteNonQuery(string commandText, params IParameter[] parameters);
///
/// Executes a command and returns a records reader containing the results.
///
/// The command text.
/// The parameters.
/// A data reader containing the results of the command.
/// If a data source error occurs.
IRecordsReader ExecuteReader(string commandText, params IParameter[] parameters);
///
/// Executes a command that returns a single value.
///
/// The type of the value.
/// The command text.
/// The parameters.
/// The return value of the command.
/// If a data source error occurs.
ScalarType ExecuteScalar(string commandText, params IParameter[] parameters);
///
/// Executes a command that returns an XML value.
///
/// The command text.
/// The parameters.
/// An XML reader containing the return value.
/// If a data source error occurs.
XmlReader ExecuteXmlReader(string commandText, params IParameter[] parameters);
}
}