public void SetId(object instance, object idValue)
        {
            var nameOfIdPropertyFieldOrProperty = getNameOfIdPropertyForType.GetNameOfIdProperty(instance.GetType());
            var idPropertyInformation           = instance.GetType().GetProperty(nameOfIdPropertyFieldOrProperty, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);

            if (idPropertyInformation.PropertyType.FullName == "System.Guid")
            {
                idPropertyInformation.SetValue(instance, new Guid(idValue.ToString()), null);
            }
            else
            {
                idPropertyInformation.SetValue(instance, idValue, null);
            }
        }
        public string GetId(object o)
        {
            var nameOfIdPropertyFieldOrProperty = getNameOfIdPropertyForType.GetNameOfIdProperty(o.GetType());
            var idPropertyInformation           = o.GetType().GetProperty(nameOfIdPropertyFieldOrProperty, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);

            if (idPropertyInformation == null)
            {
                return(o.GetType().GetField(nameOfIdPropertyFieldOrProperty, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public).GetValue(o).ToString());
            }

            var value = idPropertyInformation.GetValue(o, null);

            if ((value != null) && (value.ToString() == new Guid().ToString()))
            {
                value = null;
            }

            return(value == null ? null : value.ToString());
        }