Beispiel #1
0
        /// <inheritdoc />
        public string GetNameForEntitySet(EntityMetadata entityMetadata, IServiceProvider services)
        {
            string value = _defaultService.GetNameForEntitySet(entityMetadata, services);

            value = ModifyPublisher(value);
            return(value);
        }
        public string GetNameForEntitySet(EntityMetadata entityMetadata, IServiceProvider services)
        {
            var entityName = SingleEntityConfiguration.Instance.GetEntityAlternateName();

            if (!string.IsNullOrWhiteSpace(entityName))
            {
                return(entityName + "Set");
            }

            return(namingService.GetNameForEntitySet(entityMetadata, services));
        }
        public string GetNameForEntitySet(EntityMetadata entityMetadata, IServiceProvider services)
        {
            if (entityMetadata == null)
            {
                throw new ArgumentNullException(nameof(entityMetadata));
            }
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (removePublisherPrefix)
            {
                var metadataService = (IMetadataProviderService)services.GetService(typeof(IMetadataProviderService));

                var noPrefixName = entityMetadata.IsCustomEntity == true?entityMetadata.EntitySetName.Substring(entityMetadata.EntitySetName.IndexOf("_", StringComparison.InvariantCulture) + 1) : entityMetadata.EntitySetName;

                var result = noPrefixName;
                var equal  = metadataService.LoadMetadata().Entities.Where(x => noPrefixName == (x.IsCustomEntity == true ? x.EntitySetName.Substring(x.EntitySetName.IndexOf("_", StringComparison.InvariantCulture) + 1) : x.EntitySetName)).Select(x => new string[] { x.EntitySetName, x.IsCustomEntity == true ? x.EntitySetName.Substring(x.EntitySetName.IndexOf("_", StringComparison.InvariantCulture) + 1) : x.EntitySetName }).ToArray();
                if (equal.Length > 1)
                {
                    for (int i = 0; i < equal.Length; i++)
                    {
                        if (equal[i][0] == entityMetadata.EntitySetName)
                        {
                            result = equal[i][1] + (i + 1);
                            break;
                        }
                    }
                }
                return(result);
            }
            else
            {
                return(namingService.GetNameForEntitySet(entityMetadata, services));
            }
        }