/// <summary>
        /// Serialize the <see cref="RequestForWaiver"/>
        /// </summary>
        /// <param name="requestForWaiver">The <see cref="RequestForWaiver"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(RequestForWaiver requestForWaiver)
        {
            var jsonObject = new JObject();

            jsonObject.Add("approvedBy", this.PropertySerializerMap["approvedBy"](requestForWaiver.ApprovedBy.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("author", this.PropertySerializerMap["author"](requestForWaiver.Author));
            jsonObject.Add("category", this.PropertySerializerMap["category"](requestForWaiver.Category.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("classification", this.PropertySerializerMap["classification"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationClassificationKind), requestForWaiver.Classification)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), requestForWaiver.ClassKind)));
            jsonObject.Add("content", this.PropertySerializerMap["content"](requestForWaiver.Content));
            jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](requestForWaiver.CreatedOn));
            jsonObject.Add("discussion", this.PropertySerializerMap["discussion"](requestForWaiver.Discussion.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](requestForWaiver.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](requestForWaiver.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](requestForWaiver.Iid));
            jsonObject.Add("languageCode", this.PropertySerializerMap["languageCode"](requestForWaiver.LanguageCode));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](requestForWaiver.ModifiedOn));
            jsonObject.Add("owner", this.PropertySerializerMap["owner"](requestForWaiver.Owner));
            jsonObject.Add("primaryAnnotatedThing", this.PropertySerializerMap["primaryAnnotatedThing"](requestForWaiver.PrimaryAnnotatedThing));
            jsonObject.Add("relatedThing", this.PropertySerializerMap["relatedThing"](requestForWaiver.RelatedThing.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](requestForWaiver.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](requestForWaiver.ShortName));
            jsonObject.Add("sourceAnnotation", this.PropertySerializerMap["sourceAnnotation"](requestForWaiver.SourceAnnotation.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("status", this.PropertySerializerMap["status"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationStatusKind), requestForWaiver.Status)));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](requestForWaiver.ThingPreference));
            jsonObject.Add("title", this.PropertySerializerMap["title"](requestForWaiver.Title));
            return(jsonObject);
        }
        /// <summary>
        /// Persist the DTO composition to the ORM layer.
        /// </summary>
        /// <param name="transaction">
        /// The transaction object.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="requestForWaiver">
        /// The requestForWaiver instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool CreateContainment(NpgsqlTransaction transaction, string partition, RequestForWaiver requestForWaiver)
        {
            var results = new List <bool>();

            foreach (var relatedThing in this.ResolveFromRequestCache(requestForWaiver.RelatedThing))
            {
                results.Add(this.ModellingThingReferenceService.CreateConcept(transaction, partition, relatedThing, requestForWaiver));
            }

            foreach (var discussion in this.ResolveFromRequestCache(requestForWaiver.Discussion))
            {
                results.Add(this.EngineeringModelDataDiscussionItemService.CreateConcept(transaction, partition, discussion, requestForWaiver));
            }

            foreach (var approvedBy in this.ResolveFromRequestCache(requestForWaiver.ApprovedBy))
            {
                results.Add(this.ApprovalService.CreateConcept(transaction, partition, approvedBy, requestForWaiver));
            }

            return(results.All(x => x));
        }
        /// <summary>
        /// Persist the <see cref="RequestForWaiver"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="requestForWaiver">
        /// The <see cref="RequestForWaiver"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, RequestForWaiver requestForWaiver)
        {
            var results = new List <bool>();

            foreach (var approvedBy in this.ResolveFromRequestCache(requestForWaiver.ApprovedBy))
            {
                results.Add(this.ApprovedByService.UpsertConcept(transaction, partition, approvedBy, requestForWaiver));
            }

            foreach (var discussion in this.ResolveFromRequestCache(requestForWaiver.Discussion))
            {
                results.Add(this.DiscussionService.UpsertConcept(transaction, partition, discussion, requestForWaiver));
            }

            foreach (var relatedThing in this.ResolveFromRequestCache(requestForWaiver.RelatedThing))
            {
                results.Add(this.RelatedThingService.UpsertConcept(transaction, partition, relatedThing, requestForWaiver));
            }

            return(results.All(x => x));
        }