Inheritance: ConnectionScopeBase, IDisposable
Example #1
0
        /// <summary>
        /// Creates a new <see cref="Thread"/> object and copies
        /// the current <see cref="ConnectionScope"/> parameters.
        /// </summary>
        /// <param name="start">A delegate specifying which method to run
        /// when the <see cref="Thread"/> is started.</param>
        /// <returns>Returns a new <see cref="Thread"/> object.</returns>
        public static Thread NewThread(ParameterizedThreadStart start)
        {
            ConnectionScope scope = ConnectionScope.Current;

            Thread t = new Thread(delegate(Object obj)
            {
                ConnectionScope.Copy(scope);
                start(obj);
            });

            return(t);
        }
Example #2
0
        /// <summary>
        /// Creates a new <see cref="Thread"/> object and copies
        /// the current <see cref="ConnectionScope"/> parameters.
        /// </summary>
        /// <param name="start">A delegate specifying which method to run
        /// when the <see cref="Thread"/> is started.</param>
        /// <returns>Returns a new <see cref="Thread"/> object.</returns>
        public static Thread NewThread(ThreadStart start)
        {
            ConnectionScope scope = ConnectionScope.Current;

            Thread t = new Thread(delegate()
            {
                ConnectionScope.Copy(scope);
                start();
            });

            return(t);
        }
Example #3
0
        /// <summary>
        /// Gets a page of entity rows with a <see cref="TList{VJobCandidateEducation}" /> from the DataSource with a where clause and order by clause.
        /// </summary>
        /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param>
        /// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC).</param>
        /// <param name="start">Row number at which to start reading.</param>
        /// <param name="pageLength">Number of rows to return.</param>
        /// <param name="totalCount">Out Parameter, Number of rows in the DataSource.</param>
        /// <remarks></remarks>
        /// <returns>Returns a typed collection of <c>VJobCandidateEducation</c> objects.</returns>
        public override VList <VJobCandidateEducation> GetPaged(string whereClause, string orderBy, int start, int pageLength, out int totalCount)
        {
            // throws security exception if not authorized
            //SecurityContext.IsAuthorized("GetPaged");

            // get this data
            VList <VJobCandidateEducation> list = null;

            totalCount = -1;
            TransactionManager transactionManager = null;

            try
            {
                //since this is a read operation, don't create a tran by default, only use tran if provided to us for custom isolation level
                transactionManager = ConnectionScope.ValidateOrCreateTransaction(noTranByDefault);
                NetTiersProvider dataProvider = ConnectionScope.Current.DataProvider;

                //Access repository
                list = dataProvider.VJobCandidateEducationProvider.GetPaged(transactionManager, whereClause, orderBy, start, pageLength, out totalCount);

                //if borrowed tran, leave open for next call
            }
            catch (Exception exc)
            {
                //if open, rollback, it's possible this is part of a larger commit
                if (transactionManager != null && transactionManager.IsOpen)
                {
                    transactionManager.Rollback();
                }

                //Handle exception based on policy
                if (DomainUtil.HandleException(exc, layerExceptionPolicy))
                {
                    throw;
                }
            }
            return(list);
        }
Example #4
0
        /// <summary>
        ///     Returns rows from the DataSource that meet the parameter conditions.
        /// </summary>
        /// <param name="parameters">A collection of <see cref="SqlFilterParameter"/> objects.</param>
        /// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param>
        /// <param name="start">Row number at which to start reading.</param>
        /// <param name="pageLength">Number of rows to return.</param>
        /// <param name="count">out. The number of rows that match this query.</param>
        /// <returns>Returns a typed collection of <c>VProductModelInstructions</c> objects.</returns>
        public override VList <VProductModelInstructions> Find(IFilterParameterCollection parameters, string orderBy, int start, int pageLength, out int count)
        {
            // throws security exception if not authorized
            //SecurityContext.IsAuthorized("Find");

            // get this data
            TransactionManager transactionManager  = null;
            VList <VProductModelInstructions> list = null;

            count = -1;

            try
            {
                //since this is a read operation, don't create a tran by default, only use tran if provided to us for custom isolation level
                transactionManager = ConnectionScope.ValidateOrCreateTransaction(noTranByDefault);
                NetTiersProvider dataProvider = ConnectionScope.Current.DataProvider;

                //Access repository
                list = dataProvider.VProductModelInstructionsProvider.Find(transactionManager, parameters, orderBy, start, pageLength, out count);
            }
            catch (Exception exc)
            {
                //if open, rollback, it's possible this is part of a larger commit
                if (transactionManager != null && transactionManager.IsOpen)
                {
                    transactionManager.Rollback();
                }

                //Handle exception based on policy
                if (DomainUtil.HandleException(exc, layerExceptionPolicy))
                {
                    throw;
                }
            }

            return(list);
        }
Example #5
0
		/// <summary>
		/// Copies the values from the specified <paramref name="scope"/> object
		/// to the <see cref="ConnectionScope"/> used by the current thread.
		/// </summary>
		/// <param name="scope">A <see cref="ConnectionScope"/> object.</param>
		private static void Copy(ConnectionScope scope)
		{
			ConnectionScope newScope = ConnectionScope.Current;
			newScope.ConnectionStringKey = scope.ConnectionStringKey;
			newScope.DynamicConnectionString = scope.DynamicConnectionString;
            newScope.TransactionManager = scope.TransactionManager;
            newScope.DataProvider = scope.DataProvider;
		}