Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GriffinCaching : Closed Connection #47

Open
KingR1 opened this issue Apr 2, 2014 · 0 comments
Open

GriffinCaching : Closed Connection #47

KingR1 opened this issue Apr 2, 2014 · 0 comments

Comments

@KingR1
Copy link

KingR1 commented Apr 2, 2014

I am using MS Sql 2012.
Some times i get error "ExecuteScalar requires an open and available Connection. The connection's current state is closed."
This error i get in subclass of ViewLocalizer and RepositoryStringProvider :

// Caching view texts
public class CachedViewLocalizer : ViewLocalizer
{
    private readonly ILocalizedViewsCache _cache;

    public CachedViewLocalizer(IViewLocalizationRepository repository, ILocalizedViewsCache cache) : base(repository) 
    {
        _cache = cache;
    }

    public override string Translate(string viewPath, RouteData routeData, string text)
    {
        string prompt;
        if (_cache.TryGetValue(viewPath, routeData, text, out prompt))
            return prompt;

        if (prompt != null)
        {
            prompt = base.Translate(viewPath, routeData, text);// THIS LINE THROW ERROR
        }

        _cache.Insert(viewPath, routeData, text, prompt);
        return prompt;
    }
}

// caching type translations
public class CachedTypeLocalizer : RepositoryStringProvider
{
    private readonly ILocalizedTypesCache _cache;

    public CachedTypeLocalizer(ILocalizedTypesRepository repository, ILocalizedTypesCache cache) : base(repository)
    {
        _cache = cache;
    }

    protected override string Translate(Type type, string name)
    {
        var promptName = type.FullName + "." + name;

        string prompt;
        if (_cache.TryGetValue(promptName, out prompt))
                return prompt;

        prompt = base.Translate(type, name);
        if (prompt != null)
        {
            _cache.Insert(promptName, prompt);    
        }

        return prompt;
    }
}

After re-build of project everything works again.
So i think, Griffin.MvcContrib close connection.

Maybe some suggestions?
Thanks, Roman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant