コード例 #1
0
ファイル: BaseProviderDb.cs プロジェクト: bugjohnyang/YAFNET
        protected BaseProviderDb(string connectionStringAppKeyName)
        {
            this._dbAccess = new Lazy<IDbAccess>(() =>
            {
                var access = new MsSqlDbAccess((p) => DbProviderFactories.GetFactory(p), new QueryProfile());
                var old = access.Information.ConnectionString;
                access.Information.ConnectionString = () =>
                {
                    string connStr;
                    return ProviderConnectionStrings.TryGetValue(connectionStringAppKeyName, out connStr) ? connStr : old();
                };

                return access;
            });
        }
コード例 #2
0
ファイル: BaseProviderDb.cs プロジェクト: jiahello/MyForum
        protected BaseProviderDb(string connectionStringAppKeyName)
        {
            this._dbAccess = new Lazy<IDbAccess>(() =>
            {
                var access = new MsSqlDbAccess((p) => DbProviderFactories.GetFactory(p), new QueryProfile());
                var old = access.Information.ConnectionString;
                access.Information.ConnectionString = () =>
                {
                    if (YafContext.Application[connectionStringAppKeyName] != null)
                    {
                        return YafContext.Application[connectionStringAppKeyName] as string;
                    }

                    return old();
                };

                return access;
            });
        }