示例#1
0
        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();
            }
        }