/// <summary>
        /// Gets the data schema version of the database. May return null. Examples: "2.3.3421", "2.4.1"
        /// </summary>
        /// <returns>Returns an instance of <see cref="GalleryDataSchemaVersion"/> containing the database version.</returns>
        public static GalleryDataSchemaVersion GetDataSchemaVersion(DataSet ds)
        {
            var          asTableNames = new[] { "AppSetting", "gs_AppSetting" };
            const string filter       = "SettingName = 'DataSchemaVersion'";

            foreach (var asTableName in asTableNames)
            {
                if (!ds.Tables.Contains(asTableName))
                {
                    continue;
                }

                var dr = ds.Tables[asTableName].Select(filter).FirstOrDefault();

                if (dr == null)
                {
                    throw new Exception(String.Format("The table {0} does not contain a row where {1}.", asTableName, filter));
                }

                return(GalleryDataSchemaVersionEnumHelper.ConvertGalleryDataSchemaVersionToEnum(dr["SettingValue"].ToString()));
            }

            throw new Exception(String.Format("The backup file does not contain one of the following required tables: {0} or {1}.", asTableNames[0], asTableNames[1]));
        }
 /// <summary>
 /// Returns the current data schema version as defined in the AppSetting table.
 /// </summary>
 /// <returns>An instance of <see cref="GalleryDataSchemaVersion" /> indicating the current data schema version
 /// as defined in the AppSetting table.</returns>
 private static GalleryDataSchemaVersion GetCurrentSchema(GalleryDb ctx)
 {
     return(GalleryDataSchemaVersionEnumHelper.ConvertGalleryDataSchemaVersionToEnum(ctx.AppSettings.First(a => a.SettingName == "DataSchemaVersion").SettingValue));
 }
예제 #3
0
 /// <summary>
 /// Gets the version of the objects in the database as reported by the database. If the version cannot be parsed into one of the
 /// <see cref="GalleryDataSchemaVersion" /> values, then GalleryDataSchemaVersion.Unknown is returned.
 /// </summary>
 /// <returns>Returns an instance of <see cref="GalleryDataSchemaVersion" /> representing the version of the objects in the database.</returns>
 internal static GalleryDataSchemaVersion GetDataSchemaVersion()
 {
     return(GalleryDataSchemaVersionEnumHelper.ConvertGalleryDataSchemaVersionToEnum(GetDataSchemaVersionString()));
 }