Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Setting Command Timeout - Entity Framework 6 - .NET Framework

RSS
Modified on Wed, Oct 12, 2016, 1:46 PM by Administrator Categorized as ·Net Framework
public static class DbContextExtensions
{
    public enum ConfiguredCommand{SalesReport}

    public static void SetConfiguredCommandTimeout(this MyDbContext db, ConfiguredCommand cmd)
    {
        var appSetting = "CommandTimeout." + cmd.ToString();
        var s = ConfigurationManager.AppSettings[appSetting];
        int n;

        if (int.TryParse(s, out n))
            db.Database.CommandTimeout = n;

    }
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.