/// <summary>
 /// Create a LearningStoreItemIdentifier from some data within a row of a
 /// LogableSqlCommand
 /// </summary>
 /// <param name="command">The LogableSqlCommand.  The current position is
 ///     not modified.</param>
 /// <param name="startingColumn">The index of the first column to be
 ///     examined.  On exit, this index contains the last column examined
 ///     plus one.</param>
 /// <param name="itemType">Information about the identifier type to be
 ///     created.</param>
 /// <returns>The<Typ>LearningStoreItemIdentifier</Typ>, or null if
 ///     a value is not found.</returns>
 /// <remarks>Only examines one column.  Assumes that the column contains
 ///     an int64 value, containing the key of the Id.  If the column is
 ///     non-null, a LearningStoreItemIdentifier is returned.  If the
 ///     column is null, null is returned.
 /// </remarks>
 private static LearningStoreItemIdentifier ReadItemIdentifierColumns(LogableSqlCommand command,
                                                                      ref int startingColumn, LearningStoreItemType itemType)
 {
     if (command.IsDBNull(startingColumn))
     {
         startingColumn++;
         return(null);
     }
     else
     {
         long idkey = command.GetInt64(startingColumn);
         startingColumn++;
         return(new LearningStoreItemIdentifier(itemType.Name, idkey));
     }
 }
        /// <summary>
        /// Create a LearningStoreItemIdentifier from a result within a LogableSqlCommand
        /// </summary>
        /// <param name="command">The LogableSqlCommand.  On exit, the entire
        ///     current result has been read.</param>
        /// <param name="itemType">Information about the item type that should be read.</param>
        /// <returns>The<Typ>LearningStoreItemIdentifier</Typ></returns>
        /// <remarks>Assumes that the result has one rows.  Assumes that the
        ///     columns within the row contain exactly the correct data
        ///     for the <Mth>ReadItemIdentifierColumns</Mth> method.</remarks>
        public static LearningStoreItemIdentifier ReadItemIdentifierResult(LogableSqlCommand command, LearningStoreItemType itemType)
        {
            // Check input parameters
            if (command == null)
            {
                throw new LearningComponentsInternalException("LSTR1000");
            }
            if (itemType == null)
            {
                throw new LearningComponentsInternalException("LSTR1010");
            }

            if (!command.Read())
            {
                throw new LearningComponentsInternalException("LSTR1020");
            }

            // Start at the first column
            int startingColumn = 0;

            // Read the item
            LearningStoreItemIdentifier id = ReadItemIdentifierColumns(command,
                                                                       ref startingColumn, itemType);

            // Verify that the correct number of values are in the row
            if (command.GetFieldCount() != startingColumn)
            {
                throw new LearningComponentsInternalException("LSTR1030");
            }

            if (command.Read())
            {
                throw new LearningComponentsInternalException("LSTR1040");
            }

            return(id);
        }