/// <summary> /// Get the default schema compiled from the database. /// For a config variable, we fetch a static defined server, database and schema from the application's metadata to show "intellisence". /// </summary> /// <param name="schemaName">Could be a name like DBO or a variable like {$KEY{SERVER_VALUE}{DATABASE_VALUE}{SCHEMA_VALUE}} /// OR {$DATABASE_SOURCE{1}{myDb}{dbo}}.</param> /// <param name="databaseMetadata">Metadatas</param> /// <param name="appMetadata">App metadata</param> private static SchemaMetadata GetSchemaMetadata(DatabaseMetadata databaseMetadata, AppMetadata appMetadata, string schemaName) { if (String.IsNullOrEmpty(schemaName)) { throw new ArgumentNullException("databaseMetadata"); } schemaName = schemaName.ToLower(); //If is a schema name if (databaseMetadata.ContainsKey(schemaName)) { return(databaseMetadata[schemaName]); } //If is a variable var v = schemaName.ParseConfigVariable(); if (v != null && appMetadata.ContainsKey(v.Server) && appMetadata[v.Server].ContainsKey(v.Database) && appMetadata[v.Server][v.Database].ContainsKey(v.Schema)) { return(appMetadata[v.Server][v.Database][v.Schema]); } throw new ConfigurationException(String.Format("Schema not found in the configuration. Name : {0}", schemaName)); }