public static PropertyDefinition GetParentNavigationProperty(this ForeignKey foreignKey, ITable table, EntityFrameworkCoreProject project)
        {
            var propertyType = "";

            if (table.HasSameEnclosingName())
            {
                propertyType = string.Join(".", (new string[]
                {
                    project.ProjectNamespaces.EntityLayer,
                    project.Database.HasDefaultSchema(table) ? string.Empty : table.Schema, project.GetEntityName(table)
                }).Where(item => !string.IsNullOrEmpty(item)));
            }
            else
            {
                propertyType = project.GetEntityName(table);
            }

            var selection = project.GetSelection(table);

            return(new PropertyDefinition(propertyType, $"{project.GetEntityName(table)}Fk")
            {
                AccessModifier = AccessModifier.Public,
                IsVirtual = selection.Settings.DeclareNavigationPropertiesAsVirtual,
                Attributes = selection.Settings.UseDataAnnotations ? new List <MetadataAttribute>
                {
                    new MetadataAttribute("ForeignKey", $"\"{string.Join(",", foreignKey.Key)}\"")
                } : null
            });
        }
        public static PropertyDefinition GetParentNavigationProperty(this ForeignKey foreignKey, ITable table, EntityFrameworkCoreProject project)
        {
            var propertyType = string.Join(".", (new string[] { project.Name, project.ProjectNamespaces.EntityLayer, project.Database.HasDefaultSchema(table) ? string.Empty : table.Schema, project.GetEntityName(table) }).Where(item => !string.IsNullOrEmpty(item)));

            var selection = project.GetSelection(table);

            return(new PropertyDefinition(propertyType, string.Format("{0}Fk", project.GetEntityName(table)))
            {
                IsVirtual = selection.Settings.DeclareNavigationPropertiesAsVirtual,
                Attributes = selection.Settings.UseDataAnnotations ? new List <MetadataAttribute> {
                    new MetadataAttribute("ForeignKey", string.Format("\"{0}\"", string.Join(",", foreignKey.Key)))
                } : null
            });
        }
 public static string GetRemoveRepositoryMethodName(this EntityFrameworkCoreProject project, ITable table)
 => string.Format("Remove{0}Async", project.GetEntityName(table));
 public static string GetGetByUniqueRepositoryMethodName(this EntityFrameworkCoreProject project, ITable table, Unique unique)
 => string.Format("Get{0}By{1}Async", project.GetEntityName(table), string.Join("And", unique.Key.Select(item => project.CodeNamingConvention.GetPropertyName(item))));
 public static string GetGetRepositoryMethodName(this EntityFrameworkCoreProject project, IDbObject dbObject)
 => string.Format("Get{0}Async", project.GetEntityName(dbObject));
 public static string GetFullEntityConfigurationName(this EntityFrameworkCoreProject project, IDbObject dbObject)
 => string.Join(".", project.CodeNamingConvention.GetNamespace(project.ProjectNamespaces.Configurations), project.CodeNamingConvention.GetNamespace(dbObject.Schema), string.Format("{0}Configuration", project.GetEntityName(dbObject)));
 public static string GetEntityConfigurationName(this EntityFrameworkCoreProject project, IDbObject dbObject)
 => string.Format("{0}Configuration", project.GetEntityName(dbObject));
 public static string GetFullDbSetPropertyName(this EntityFrameworkCoreProject project, IDbObject dbObject)
 => project.NamingService.Pluralize(string.Concat(project.CodeNamingConvention.GetNamespace(dbObject.Schema), project.GetEntityName(dbObject)));
 public static string GetDbSetPropertyName(this EntityFrameworkCoreProject project, IDbObject dbObject, bool pluralize)
 => pluralize?project.NamingService.Pluralize(project.GetEntityName(dbObject)) : project.GetEntityName(dbObject);
 public static string GetPluralName(this EntityFrameworkCoreProject project, IDbObject dbObject)
 => project.NamingService.Pluralize(project.GetEntityName(dbObject));
        public static PropertyDefinition GetChildNavigationProperty(this EntityFrameworkCoreProject project, ProjectSelection <EntityFrameworkCoreProjectSettings> projectSelection, ITable table, ForeignKey foreignKey)
        {
            var propertyType = string.Format("{0}<{1}>", projectSelection.Settings.NavigationPropertyEnumerableType, project.GetEntityName(table));

            return(new PropertyDefinition(propertyType, project.GetNavigationPropertyName(table))
            {
                AccessModifier = AccessModifier.Public,
                IsVirtual = projectSelection.Settings.DeclareNavigationPropertiesAsVirtual
            });
        }