Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Hive/3.3/Interfaces/IConnectionProvider.cs @ 11603

Last change on this file since 11603 was 8326, checked in by fschoepp, 12 years ago

#1888:

  • Added IConnectionProvider interface + implementation based on jheinzelreiters transaction management
  • Fixed transaction being promoted to dtc; transactions enabled again
  • Changed HiveDao: transactions are managed properly
File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using System.Data.Common;
27
28namespace HeuristicLab.Services.Hive.Interfaces {
29  /// <summary>
30  /// This interface provides functionality to create transactionscoped and non-transactionscoped database connection.
31  /// It also helps to clean the connections after their last usage.
32  /// </summary>
33  public interface IConnectionProvider {
34    /// <summary>
35    /// Creates or returns an already opened database connection for the given connectionStringName.
36    /// If there is no surrounding transaction, a new connection will be returned. This connection
37    /// must be closed by using the ReleaseConnection method.
38    /// If there is a surrounding transaction and no connection exists for the connectionStringName,
39    /// a new connection will be returned.
40    /// If there is a surrounding transaction and an existing connection for the connectionStringName,
41    /// the existing connection will be returned.
42    /// </summary>
43    /// <param name="connectionStringName">The name of the connectionString within the app.config (or web.config) file</param>
44    /// <returns>
45    /// A new connection to the database. If a transaction is already open for this connectionString,
46    /// the same connection will be returned. Whenever a connection is not needed anymore, call the
47    /// ReleaseConnection to release it properly.
48    /// </returns>
49    DbConnection GetOpenConnection(string connectionStringName);
50    /// <summary>
51    /// Releases a given database connection only if there is no active transaction.
52    /// Note: Connections within transactions will be released automatically after the transaction ended,
53    /// if the user created the connection with GetOpenConnection within a transaction.
54    /// </summary>
55    /// <param name="connection"></param>
56    void ReleaseConnection(DbConnection connection);
57  }
58}
Note: See TracBrowser for help on using the repository browser.