Пример #1
0
        /// <summary>
        /// Closes the conenction with the DB
        /// </summary>
        public static void CloseConnection()
        {
            if (_session == null)
            {
                throw new ConnectionNotOpened();
            }

            _session.Close();
            _session = null;
        }
Пример #2
0
        /// <summary>
        /// Creates a new connection to the repository,
        /// will throw an exception if the connection was already created
        /// </summary>
        /// <returns>The created connection</returns>
        public static IPersistanceConnection GetNewConnection()
        {
            if (_session != null)
            {
                throw new ConnectionAlreadyOpened();
            }

            _session = GetConnectionProvider().GetConnection();
            _session.SetNotifier(SesionScopeComplete);

            return(_session);
        }
Пример #3
0
 /// <summary>
 /// Add dependency injection through the constructor
 /// </summary>
 /// <param name="connection">database connection</param>
 /// <param name="serviceClient">service client</param>
 public PartInvoiceController(IPersistanceConnection connection, IPartAvailabilityServiceClient serviceClient)
 {
     this.Connection    = connection;
     this.ServiceClient = serviceClient;
 }
Пример #4
0
 /// <summary>
 /// This is an scope helper to allow Idisposable and closing the backing connection
 /// </summary>
 public static void SesionScopeComplete()
 {
     _session = null;
 }