Exemplo n.º 1
0
        /// <summary>
        /// Gets the <see cref="WMOAreaTableRecord"/> for the given WMO ID.
        /// </summary>
        /// <param name="database">The database to search.</param>
        /// <param name="wmoID">The WMO ID key.</param>
        /// <returns>A WMOAreaTableRecord corresponding to the given ID.</returns>
        /// <exception cref="ArgumentException">
        /// Thrown if the given <see cref="ForeignKey{T}"/>is not a key for the WMO ID field.
        /// </exception>
        public static WMOAreaTableRecord GetWMOArea(this DBC <WMOAreaTableRecord> database, ForeignKey <uint> wmoID)
        {
            if (wmoID.Field != nameof(WMOAreaTableRecord.WMOID))
            {
                throw new ArgumentException("The given foreign key is not valid for searching by WMO ID.");
            }

            return(database.FirstOrDefault(x => x.WMOID == wmoID.Key));
        }