Exemplo n.º 1
0
        /// <summary>
        /// Creates the <see cref="ContextCreationOptions"/> and uses the values from the backend configuration.
        /// </summary>
        /// <returns>An instance of <see cref="ContextCreationOptions"/> which uses the values from the backend configuration.</returns>
        public static ContextCreationOptions CreateFromSettings()
        {
            ContextCreationOptions options = new ContextCreationOptions();

            options.HostName     = ServiceFactory.BackendConfigurator.Get("Server.DB.HostName");
            options.Port         = int.Parse(ServiceFactory.BackendConfigurator.Get("Server.DB.Port"));
            options.UserId       = ServiceFactory.BackendConfigurator.Get("Server.DB.UserId");
            options.Password     = ServiceFactory.BackendConfigurator.Get("Server.DB.Password");
            options.DatabaseName = ServiceFactory.BackendConfigurator.Get("Server.DB.DatabaseName");
            return(options);
        }
Exemplo n.º 2
0
        private static string CreateConnectionString()
        {
            try
            {
                return(ContextCreationOptions.CreateFromSettings().GetConnectionString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine("MainDbContext.CreateConnectionString() failed: {0}", ex.Message);
            }

            return(FallbackConnectionString);
        }