#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
namespace HeuristicLab.Services.Hive.Interfaces {
///
/// This interface provides functionality to create transactionscoped and non-transactionscoped database connection.
/// It also helps to clean the connections after their last usage.
///
public interface IConnectionProvider {
///
/// Creates or returns an already opened database connection for the given connectionStringName.
/// If there is no surrounding transaction, a new connection will be returned. This connection
/// must be closed by using the ReleaseConnection method.
/// If there is a surrounding transaction and no connection exists for the connectionStringName,
/// a new connection will be returned.
/// If there is a surrounding transaction and an existing connection for the connectionStringName,
/// the existing connection will be returned.
///
/// The name of the connectionString within the app.config (or web.config) file
///
/// A new connection to the database. If a transaction is already open for this connectionString,
/// the same connection will be returned. Whenever a connection is not needed anymore, call the
/// ReleaseConnection to release it properly.
///
DbConnection GetOpenConnection(string connectionStringName);
///
/// Releases a given database connection only if there is no active transaction.
/// Note: Connections within transactions will be released automatically after the transaction ended,
/// if the user created the connection with GetOpenConnection within a transaction.
///
///
void ReleaseConnection(DbConnection connection);
}
}