private static ClassDefinition BuildClassDefinition(IComplexProperty property, string ns, string className)
        {
            ClassDefinition definition = new ClassDefinition();
            List <ClassPropertyDefinition> classProperties = new List <ClassPropertyDefinition>();
            HashSet <string> usingNamespaces = new HashSet <string>();

            foreach (var dataEntityProperty in property.ComplexPropertyType.Properties)
            {
                var entityProperty = (DynamicProperty)dataEntityProperty;
                usingNamespaces.Add(entityProperty.PropertyType.Namespace);
                string annotation = entityProperty.Name;
                if (string.IsNullOrWhiteSpace(annotation))
                {
                    annotation = entityProperty.Name;
                }

                classProperties.Add(
                    new ClassPropertyDefinition()
                {
                    Name       = entityProperty.Name,
                    Annotation = annotation,
                    TypeName   = GetBaseTypeName(entityProperty.PropertyType)
                });
            }

            return(definition.SetAnnotation(property.Name).SetName(className).SetNamespace(ns).SetProperties(classProperties).SetUsingNamespaces(usingNamespaces));
        }
        private static List <ClassDefinition> BuildClassDefinitions(BusinessInfo businessInfo, Entity entity, string ns, string formId)
        {
            List <ClassDefinition> results = new List <ClassDefinition>();

            ClassDefinition definition = new ClassDefinition();
            List <ClassPropertyDefinition> classProperties = new List <ClassPropertyDefinition>(entity.DynamicObjectType.Properties.Count);
            HashSet <string> usingNamespaces = new HashSet <string>();

            List <Field> fields = entity.Fields;

            foreach (DynamicProperty property in entity.DynamicObjectType.Properties)
            {
                Field  field          = fields.FirstOrDefault(u => u.PropertyName.Equals(property.Name));
                string usingNamespace = GetNamespaceName(property);
                if (!string.IsNullOrWhiteSpace(usingNamespace))
                {
                    usingNamespaces.Add(usingNamespace);
                }

                string annotation = field?.Name;
                if (string.IsNullOrWhiteSpace(annotation))
                {
                    annotation = property.Name;
                }

                string type = GetPropertyTypeName(property, field);
                string name = property.Name;

                // 基础资料类型属性、单选辅助资料属性
                if (property is IComplexProperty complexProperty)
                {
                    string lookUpObjectId = GetFieldLookUpObjectId(field);

                    type = lookUpObjectId;
                    results.Add(BuildClassDefinition(complexProperty, ns, lookUpObjectId));
                }

                var singlePropertyDefinition = new ClassPropertyDefinition()
                {
                    Name = name, Annotation = annotation, TypeName = type
                };
                //给字段加上数据表列的特性
                if (field != null)
                {
                    singlePropertyDefinition.Attributes.Add($"[Column(\"{field.FieldName}\")]");
                }
                else
                {
                    if (property == entity.DynamicObjectType.PrimaryKey)
                    {
                        singlePropertyDefinition.Attributes.Add($"[Column(\"{entity.EntryPkFieldName}\")]");
                    }
                    else if (property == businessInfo.GetForm().MasterIdDynamicProperty)
                    {
                        singlePropertyDefinition.Attributes.Add($"[Column(\"{businessInfo.GetForm().MasterPKFieldName}\")]");
                    }
                    else if (entity.SeqDynamicProperty == property)
                    {
                        singlePropertyDefinition.Attributes.Add($"[Column(\"{entity.SeqFieldKey}\")]");
                    }
                }


                classProperties.Add(singlePropertyDefinition);
            }

            string className       = GetClassName(entity, formId);
            var    classDefinition = definition.SetAnnotation(entity.Name).SetName(className).SetNamespace(ns)
                                     .SetProperties(classProperties).SetUsingNamespaces(usingNamespaces);

            if (!string.IsNullOrWhiteSpace(entity.TableName))
            {
                classDefinition.AddAttribute($"[Table(\"{entity.TableName}\")]");
#warning 需自行定义Table特性所在命名空间(.NET 4.0不提供Table特性定义)ref:https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.schema.tableattribute?view=netframework-4.8&viewFallbackFrom=netframework-4.0
                classDefinition.AddUsingNamespaces("Kingdee.Vincent.Core.Domain.Entities");
            }

            results.Add(classDefinition);
            return(results);
        }