/// <summary>
        /// Creates and returns a string representation of the current exception.
        /// </summary>
        /// <param name="includeState">Boolean</param>
        /// <returns>
        /// A string representation of the current exception.
        /// </returns>
        /// <PermissionSet>
        ///     <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="*AllFiles*"/>
        /// </PermissionSet>
        public string ToString(bool includeState)
        {
            var sb = new StringBuilder();

            if (BrokenRules.Count == 1)
            {
                sb.Append("1 broken rule. All rules must pass.");
            }
            else
            {
                sb.AppendFormat("{0} broken rules. All rules must pass.", BrokenRules.Count);
            }

            sb.AppendLine();

            foreach (KeyValuePair <object, List <BrokenRule> > entity in BrokenRules.GroupByEntity())
            {
                if (entity.Key != null && entity.Key is ILinqEntity)
                {
                    sb.AppendLine();
                    sb.AppendFormat("Type: {0}", entity.Key.GetType().Name);
                    sb.AppendLine();
                }

                foreach (BrokenRule rule in entity.Value)
                {
                    sb.AppendFormat("  - {0}", rule.Message);
                    sb.AppendLine();
                }
                sb.AppendLine();

                if (includeState && entity.Key != null && entity.Key is ILinqEntity)
                {
                    sb.AppendLine("  State:");
                    sb.AppendLine(((ILinqEntity)entity.Key).ToEntityString(2, "  "));
                }
            }

            return(sb.ToString());
        }