/// <summary>
        /// Adds a search clause to the current criteria based on the MDM <see cref="EntityId" />
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="searchField"></param>
        /// <param name="entity"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static SearchCriteria AddMdmIdCriteria(this SearchCriteria criteria, string searchField, IMdmEntity entity, SearchCondition condition = SearchCondition.Equals)
        {
            var nexusId = entity.ToMdmKeyString();

            criteria.AddCriteria(searchField, condition, nexusId, true);

            return(criteria);
        }
        /// <summary>
        /// Adds a search clause to the current criteria based on a MDM <see cref="EntityId" />
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="searchField"></param>
        /// <param name="entity"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static SearchCriteria AddEntityIdCriteria(this SearchCriteria criteria, string searchField, EntityId entity, SearchCondition condition = SearchCondition.Equals)
        {
            // null string translated to Is Null query in MDM service
            var nexusId = "null";

            // if entity is set we will by now have found its id by now.
            if (entity != null)
            {
                nexusId = entity.Identifier.Identifier;
            }

            criteria.AddCriteria(searchField, condition, nexusId, true);
            return(criteria);
        }