Esempio n. 1
0
        /// <summary>
        /// 初始化Sql语句参数类
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="columnName">字段名</param>
        /// <param name="action">赋值操作</param>
        private DataParameter(AbstractDatabase database, String columnName, String action)
        {
            this._parameter = new SqlParameter();
            this._parameter.SourceColumn = columnName;
            this._parameter.Value        = action;

            this._isUseParameter = false;
        }
Esempio n. 2
0
        /// <summary>
        /// 创建新的Sql语句参数类
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="columnName">字段名</param>
        /// <param name="parameterIndex">参数索引</param>
        /// <param name="dataType">字段类型</param>
        /// <param name="value">赋值内容</param>
        /// <returns>Sql语句参数类</returns>
        internal static DataParameter InternalCreate(AbstractDatabase database, String columnName, String parameterIndex, DataType dataType, Object value)
        {
            DataParameter param = new DataParameter(database, columnName, parameterIndex, value);

            param._parameter.DbType = DataParameter.GetDbType(dataType);

            return(param);
        }
Esempio n. 3
0
        /// <summary>
        /// 获取数据库连接
        /// </summary>
        /// <param name="db">数据库</param>
        /// <returns>数据库连接</returns>
        internal static DatabaseConnectionWrapper GetConnection(AbstractDatabase db)
        {
            SystemTransaction currentTransaction = SystemTransaction.Current;

            if (currentTransaction == null)
            {
                return(null);
            }

            Dictionary <SystemTransaction, Dictionary <String, DatabaseConnectionWrapper> > obj;

            Monitor.Enter(obj = TransactionConnections);
            Dictionary <String, DatabaseConnectionWrapper> connectionList;

            try
            {
                if (!TransactionConnections.TryGetValue(currentTransaction, out connectionList))
                {
                    connectionList = new Dictionary <String, DatabaseConnectionWrapper>();
                    TransactionConnections.Add(currentTransaction, connectionList);

                    currentTransaction.TransactionCompleted += new TransactionCompletedEventHandler(TransactionScopeConnections.OnTransactionCompleted);
                }
            }
            finally
            {
                Monitor.Exit(obj);
            }

            Dictionary <String, DatabaseConnectionWrapper> obj2;

            Monitor.Enter(obj2 = connectionList);
            DatabaseConnectionWrapper connection;

            try
            {
                if (!connectionList.TryGetValue(db.ConnectionString, out connection))
                {
                    connection = db.InternalGetConnection();
                    connectionList.Add(db.ConnectionString, connection);
                }

                connection.AddRef();
            }
            finally
            {
                Monitor.Exit(obj2);
            }

            return(connection);
        }
Esempio n. 4
0
        /// <summary>
        /// 初始化Sql语句参数类
        /// </summary>
        /// <param name="database">数据库</param>
        /// <param name="columnName">字段名</param>
        /// <param name="parameterIndex">参数索引</param>
        /// <param name="value">赋值内容</param>
        private DataParameter(AbstractDatabase database, String columnName, String parameterIndex, Object value)
        {
            this._parameter = new SqlParameter();
            this._parameter.SourceColumn  = columnName;
            this._parameter.ParameterName = database.InternalGetParameterName("PN_IDX_" + parameterIndex);

            if (value == null)
            {
                this._parameter.Value = DBNull.Value;
            }
            else if (value is DateTime)
            {
                DateTime dt = (DateTime)value;
                this._parameter.Value = dt.ToString("yyyy-MM-dd HH:mm:ss");
            }
            else
            {
                this._parameter.Value = value;
            }

            this._isUseParameter = true;
        }
Esempio n. 5
0
 /// <summary>
 /// 创建新的Sql语句参数类
 /// </summary>
 /// <param name="database">数据库</param>
 /// <param name="columnName">字段名</param>
 /// <param name="action">赋值操作</param>
 /// <returns>Sql语句参数类</returns>
 internal static DataParameter InternalCreateCustomAction(AbstractDatabase database, String columnName, String action)
 {
     return(new DataParameter(database, columnName, action));
 }