Esempio n. 1
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     Transaction.Dispose();
     _connection.Dispose();
     if (_exceptionConverter != null)
     {
         _exceptionConverter = null;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DBConnection"/> class.
 /// </summary>
 /// <param name="factory">The factory.</param>
 /// <param name="connectionString">The connection string.</param>
 public DBConnection(IDBFactory factory, string connectionString)
 {
     if (string.IsNullOrEmpty(connectionString))
     {
         throw new ArgumentException("connectionString is empty", "connectionString");
     }
     Factory                      = factory;
     _convertor                   = factory.CreateConvertor();
     _exceptionConverter          = factory.CreateExceptionConvertor();
     _connection                  = factory.CreateConnection();
     Transaction                  = new Transaction(_connection);
     _connection.ConnectionString = connectionString;
     try
     {
         _connection.Open();
     }
     catch (SqlException ex)
     {
         Log.Fatal("Error open cobbection to ::" + connectionString, ex);
     }
 }
 public void Add(Type type, IExceptionConverter converter)
 {
     Assert.Argument(type, nameof(type)).NotNull();
     Assert.Argument(converter, nameof(converter)).NotNull();
     _converters[type] = converter;
 }
 public void Add <T>(IExceptionConverter converter)
 {
     Add(typeof(T), converter);
 }