示例#1
0
文件: Dao.cs 项目: EaseEasy/Ticket
        public static IDao CreateFromSetting()
        {
            var dao = new Dao();
            dao.ProviderName = "System.Data.SqlClient";
            dao.ConnectionString = GetConnectionString();

            return dao;
        }
示例#2
0
文件: Dao.cs 项目: EaseEasy/Ticket
        public static IDao Create(string name = "Default")
        {
            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Setting.xml"))) {
                return CreateFromSetting();
            }

            var cnss = ConfigurationManager.ConnectionStrings[name];
            if (cnss == null) {
                throw new ArgumentException(string.Format("ConnectionString Not Found! name:{0}", name), "name");
            }

            var dao = new Dao();
            dao.ProviderName = cnss.ProviderName;
            dao.ConnectionString = cnss.ConnectionString;

            return dao;
        }