public static IEnumerable <EduHubField> ToEduHubFields(this IC7Entity c7Entity, EduHubEntity Entity) { foreach (var c7Field in c7Entity.Fields) { foreach (var field in c7Field.ToEduHubFields(c7Entity, Entity)) { yield return(field); } } }
public static IEnumerable <EduHubField> ToEduHubFields(this C7Field c7Field, IC7Entity c7Entity, EduHubEntity Entity) { var type = ParseType(c7Field.Type); var isKey = c7Entity.Keys?.Contains(c7Field.Name, StringComparer.OrdinalIgnoreCase) ?? false; var isIdentity = c7Field.IsSequence || (c7Entity.IsDbSeq && c7Entity.Fields[0] == c7Field); var isNullable = !isIdentity; if (type.FieldCount == 1) { yield return(new EduHubField( Entity: Entity, Name: c7Field.Name, Description: c7Field.SchemaComment.Trim(), Type: type.FrameworkType, TypeDescription: type.Description, TypeMaxLength: type.Precision, IsKey: isKey, IsNullable: isNullable, IsIdentity: isIdentity, ForeignParentKey: (c7Field.Relationship.Entity, c7Field.Relationship.Field) )); } else { for (int i = 0; i < type.FieldCount; i++) { yield return(new EduHubField( Entity: Entity, Name: $"{c7Field.Name}{i + 1:00}", Description: c7Field.SchemaComment.Trim(), Type: type.FrameworkType, TypeDescription: type.Description, TypeMaxLength: type.Precision, IsKey: isKey, IsNullable: isNullable, IsIdentity: isIdentity, ForeignParentKey: (c7Field.Relationship.Entity, c7Field.Relationship.Field) )); } } }