예제 #1
0
파일: DbHelper.cs 프로젝트: sanlonezhang/ql
        internal static void GetConnectionInfo(string databaseName, out string connectionString, out IDbFactory factory)
        {
            ProviderType type;

            ConnectionStringManager.GetConnectionInfo(databaseName, out connectionString, out type);
            factory = DbFactories.GetFactory(type);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseRepository"/> class.
        /// 构造函数
        /// </summary>
        /// <param name="unit">工作单元</param>
        /// <param name="name">数据库链接</param>
        /// <param name="parameters">parameters</param>
        protected BaseRepository(IUnitOfWork unit, string name, params object[] parameters)
        {
            Name       = name;
            UnitOfWork = unit;
            if (unit != null)
            {
                Cmd          = unit.Command;
                Connection   = unit.Connection;
                ProviderName = unit.ProviderName;
            }
            else
            {
                if (Connection == null)
                {
                    var coon = DbFactories.GetConnection(name);
                    Connection   = coon.DbConnection;
                    ProviderName = coon.ProviderName;
                }

                if (Connection.State != ConnectionState.Open)
                {
                    Connection.Open();
                }

                Cmd = Connection.CreateCommand();
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseRepository"/> class.
        /// 构造函数
        /// </summary>
        /// <param name="unit">工作单元</param>
        /// <param name="name">数据库链接</param>
        protected BaseRepository(IUnitOfWork unit, string name)
        {
            this.Name       = name;
            this.UnitOfWork = unit;
            if (unit != null)
            {
                this.cmd = unit.Command;
            }
            else
            {
                if (this.connection == null)
                {
                    this.connection = DbFactories.GetConnection(name);
                }

                if (this.connection.State != ConnectionState.Open)
                {
                    this.connection.Open();
                }

                this.cmd = this.connection.CreateCommand();
            }
        }