/// <summary>
 /// Gets the SQL statement to generate the next unoccupied ID value for tables without auto-increment.
 /// </summary>
 /// <param name="map">The <see cref="DbTableMap"/> providing the relevant information.</param>
 /// <returns>The appropriate SQL statement.</returns>
 internal static string GetNextIdValueSql(DbTableMap map)
 {
     string idColumn = map.GetIdColumnName();
     return string.Format("select max({0}} + 1 from {1}", idColumn, map.Table);
 }
 /// <summary>
 /// Creates the necessary SQL statement to create the next value in a sequence definition.
 /// </summary>
 /// <param name="map">The <see cref="DbTableMap"/> providing the relevant information.</param>
 /// <returns>The appropriate SQL statement.</returns>
 internal static string CreateNextSequenceValueSql(DbTableMap map)
 {
     return (map.HasSequence) ? string.Format("select nextval('{0}.{1}')", map.Schema, map.Sequence) : string.Empty;
 }
        /// <summary>
        /// Initializes the configuration values.
        /// </summary>
        /// <param name="filePath">The path to the configuration file.</param>
        private void Init(string filePath)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filePath);

            XmlNode databaseNode = doc.SelectSingleNode("Database");

            if (databaseNode != null && databaseNode.Attributes != null)
            {
                //TODO: Password encryption / decryption

                DatabaseName = XmlHelper.GetStringValue(databaseNode, "name");
                ServerName = XmlHelper.GetStringValue(databaseNode, "server");
                User = XmlHelper.GetStringValue(databaseNode, "user");
                Password = XmlHelper.GetStringValue(databaseNode, "password");
                Port = XmlHelper.GetIntValue(databaseNode, "port");

                XmlNodeList tableMapNodes = databaseNode.SelectNodes("TableMaps/TableMap");

                if (tableMapNodes != null)
                {
                    foreach (XmlNode tableMapNode in tableMapNodes)
                    {
                        DbTableMap map = new DbTableMap(tableMapNode);
                        tableMaps.Add(map.Class, map);
                    }
                }

                XmlNodeList featureCategoryNodes = databaseNode.SelectNodes("FeatureCategories/FeatureCategory");

                if (featureCategoryNodes != null)
                {
                    foreach (XmlNode featureCategoryNode in featureCategoryNodes)
                    {
                        FeatureCategories.Add(new DbFeatureCategory(featureCategoryNode));
                    }
                }
            }
        }