/// <summary>
        /// Construct the message written to the <see cref="MessageContext"/>.
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="subjects"></param>
        /// <param name="entityTypes"></param>
        /// <param name="subject"></param>
        /// <param name="entityType"></param>
        /// <returns></returns>
        private string ConstructCheckMessage(IList <EntityRef> entities, ISet <long> subjects, IDictionary <long, ISet <EntityRef> > entityTypes,
                                             long subject, KeyValuePair <long, ISet <EntityRef> > entityType)
        {
            EntityRef nameField;

            nameField = new EntityRef("core", "name");

            // Preload names of referenced entities, subjects and types
            Entity.GetField <string>(subjects.Select(e => new EntityRef(e)), nameField);
            // This was failing because the entities were instances of EntityTypeOnly which were causing failures when passes into Entity.GetField
            Entity.GetField <string>(entities.Where(e => !EntityId.IsTemporary(e.Id)).Select(e => new EntityRef(e.Id)), nameField);
            Entity.GetField <string>(entityTypes.Keys.Select(e => new EntityRef(e)), nameField);

            return(string.Format(
                       "Checking access rules for {0} to entities {1} of type {2}:",
                       string.Format("'{0}' ({1})", Entity.GetName(subject), subject),
                       string.Join(
                           ", ",
                           entityType.Value.Select(er => string.Format("'{0}' ({1})", Entity.GetName(er.Id), er.Id))),
                       string.Join(
                           ", ",
                           string.Format("'{0}' ({1})", Entity.GetName(entityType.Key), entityType.Key))));
        }