private static void SetupDatabaseContexts()
        {
            if (DatabaseContexts.Count == 0)
            {
                DatabaseContextDictionary contexts = new DatabaseContextDictionary();

                DatabaseContextConfig databaseContextConfig = (DatabaseContextConfig)ConfigurationManager.GetSection(ConfigSectionName);


                if (databaseContextConfig != null && databaseContextConfig.DatabaseContexts.Count > 0)
                {
                    for (int i = 0; i < databaseContextConfig.DatabaseContexts.Count; i++)
                    {
                        DatabaseContextElement element         = databaseContextConfig.DatabaseContexts[i];
                        DatabaseContext        databaseContext = DatabaseContextFactory.CreateFromElement(element);

                        contexts.Add(databaseContext.Name, databaseContext);

                        if (DefaultDatabaseContext == null && element.IsDefault)
                        {
                            DefaultDatabaseContext = databaseContext;
                        }
                    }

                    DatabaseContexts = contexts;

                    if (DefaultDatabaseContext == null)
                    {
                        DefaultDatabaseContext = contexts.Values.ElementAt(0);
                    }
                }
            }
        }
예제 #2
0
        internal static DatabaseContext CreateFromElement(DatabaseContextElement config)
        {
            DatabaseContext databaseContext = new DatabaseContext();

            databaseContext.Name     = config.ConnectionStringName;
            databaseContext.Provider = ProviderFactory.CreateFromElement(config);

            return(databaseContext);
        }
 internal static Provider CreateFromElement(DatabaseContextElement config)
 {
     return(CreateFromValues(config.CommandTimeout, config.ConnectionStringName, config.ProviderType));
 }