Example #1
0
        public static string GetId(this IDvEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var entityType = entity.GetType();

            if (EntityHelper.IsHubEntity(entityType))
            {
                return((entity as IDvHubEntity).GetHubData().GetId());
            }

            if (EntityHelper.IsLinkEntity(entityType))
            {
                return((entity as IDvLinkEntity).GetLinkData().GetId());
            }

            throw new Exception("Cannot get Id without data vault entity");
        }
Example #2
0
        public static bool ExistHub <THub>(this IDvEntity entity)
        {
            var hubName = typeof(THub).Name;

            return(!((string)entity.GetPropertyValue($"{hubName}.Value.{hubName.Replace(EntityHelper.HubPropertyPrefix, string.Empty)}Id.Value")).IsNullOrWhiteSpace());
        }
Example #3
0
 /// <summary>
 /// CAUTION: Some time it does not work with ReadView because some Views does not return child object Primary Key.
 /// Example: ReadViewDocument does not return HUB_ACCOUNT.PK_ACCOUNT_ID. So, this check will fail.
 /// </summary>
 public static bool Exist(this IDvEntity entity)
 {
     // TODO: need refactor Stored Procedure ReadView to ensure that always return child entity primary key.
     return(entity != null && !entity.GetId().IsNullOrWhiteSpace());
 }