public static DateTime GetProperyDateTimeValue(this ObjVerEx objVerEx, int id)
        {
            if (objVerEx.HasProperty(id))
            {
                PropertyValue pv = objVerEx.GetProperty(id);
                if (!pv.Value.IsNULL())
                {
                    return((DateTime)objVerEx.GetProperty(id).Value.Value);
                }
            }

            return(DateTime.MinValue);
        }
        public static int GetPropertyIntValue(this ObjVerEx objVerEx, int id)
        {
            if (objVerEx.HasProperty(id))
            {
                PropertyValue pv = objVerEx.GetProperty(id);
                if (!pv.Value.IsNULL())
                {
                    return((int)objVerEx.GetProperty(id).Value.Value);
                }
            }

            return(0);
        }
        public static double GetPropertyDoubleValue(this ObjVerEx objVerEx, int id)
        {
            if (objVerEx.HasProperty(id))
            {
                PropertyValue pv = objVerEx.GetProperty(id);
                if (!pv.Value.IsNULL())
                {
                    return((double)objVerEx.GetProperty(id).Value.Value);
                }
            }

            return(0.0);
        }
        public static bool?GetPropertyBooleanValue(this ObjVerEx objVerEx, int id)
        {
            if (objVerEx.HasProperty(id))
            {
                PropertyValue pv = objVerEx.GetProperty(id);
                if (!pv.Value.IsNULL())
                {
                    return((bool)objVerEx.GetProperty(id).Value.Value);
                }
            }

            return(null);
        }
        public static string GetValueListItemFromVault(this ObjVerEx objVerEx, int id, string ValueListName)
        {
            try {
                PropertyValue prop = objVerEx.GetProperty(id);
                if (prop == null)
                {
                    return(string.Empty);
                }

                Lookup lookup = prop.Value.GetValueAsLookup();
                if (lookup == null)
                {
                    return(string.Empty);
                }

                return(objVerEx.Vault.ValueListItemOperations.GetValueListItemByDisplayID(
                           (int)Enum.Parse(typeof(VL_ValueLists), ValueListName), lookup.Item.ToString()).Name);
            } catch {
                return(string.Empty);
            }
        }
        public static T GetSingleSelectLookupValueForPropertyDef <T>(this ObjVerEx objVerEx, int property_def_id, bool include_deleted = false)
            where T : IObjVerEx, new()
        {
            if (!objVerEx.HasValue(property_def_id))
            {
                return(default(T));
            }

            Lookup lookup = objVerEx.GetProperty(property_def_id).Value.GetValueAsLookup();

            if (lookup.Deleted && !include_deleted)
            {
                return(default(T));
            }

            ObjVerEx objVEx = new ObjVerEx(objVerEx.Vault, lookup.ObjectType, lookup.Item, lookup.Version);

            return(new T()
            {
                objVerEx = objVEx
            });
        }
        public static List <T> GetMultiSelectLookupValueForPropertyDef <T>(this ObjVerEx objVerEx, int property_def_id, bool include_deleted = false)
            where T : IObjVerEx, new()
        {
            if (!objVerEx.HasValue(property_def_id))             // Direct References Exist
            {
                return(new List <T>());
            }

            List <T> Items   = new List <T>();
            Lookups  lookups = objVerEx.GetProperty(property_def_id).Value.GetValueAsLookups();

            foreach (Lookup lookup in lookups)
            {
                if (lookup.Deleted && !include_deleted)
                {
                    continue;
                }

                ObjVerEx objVEx   = new ObjVerEx(objVerEx.Vault, lookup.ObjectType, lookup.Item, lookup.Version);
                T        classObj = new T()
                {
                    objVerEx = objVEx
                };

                if (null == classObj)
                {
                    continue;
                }

                if (!Items.Contains(classObj))
                {
                    Items.Add(classObj);
                }
            }

            return(Items);
        }
        public static T?GetSingleSelectValueListForPropertyDef <T>(this ObjVerEx objVerEx, int id)
            where T : struct
        {
            if (!typeof(T).IsEnum || !objVerEx.HasProperty(id))
            {
                return(default(T));
            }

            PropertyValue prop = objVerEx.GetProperty(id);

            if (prop == null)
            {
                return(null);
            }

            Lookup lookup = prop.Value.GetValueAsLookup();

            if (lookup == null || lookup.Deleted)
            {
                return(null);
            }

            return((T)Enum.Parse(typeof(T), lookup.Item.ToString()));
        }