Skip to end of metadata
Go to start of metadata

Configuration loading

Prior to use ORM it is required to initialize it: make it load its configuration from several files.

It's done instantiating  singleton class OsamesMicroOrm.Configuration.ConfigurationLoader by callings it's Instance property:

Sur cette page

var init = OsamesMicroOrm.Configuration.ConfigurationLoader.Instance;

In ORM demo webapp we suggest doing this using a static block this way:

namespace WebOrmBusinessLogic
{
    public static class OrmInitialization
    {
        internal static OsamesMicroOrm.Configuration.ConfigurationLoader Orm;
        public static void Initialization()
        {
            if (Orm == null)
                Orm = OsamesMicroOrm.Configuration.ConfigurationLoader.Instance; 
        }
        
    }
}

Where to place this call?

Initialization should happen at earliest stage of application lifecycle:

  • for a console of Winforms application, in startup class that contains "main"
  • for a web application, in Application_Start of Global.asax.cs

 Go further: technical description

In ConfigurationLoader there are several steps for ORM initialization. At each step an error check is performed that can interrupt process.
  • Reading of .xsd schema files, .xml templates and mapping files (check that these files exist)
  • Validation of XML files using their schemas
  • Chargement vers des variables internes des informations spécifiques au provider correspondant à la configuration active (implique vérification qu'une connexion active est définie, qu'il y a des informations de chaîne de connexion associée, que le provider correspondant est trouvé sur le système)
  • Chargement vers des dictionnaires internes des informations de templates 
  • Chargement vers des dictionnaires internes des informations de mapping.

  • No labels