private IEnumerable <PropertyDeclarationSyntax> GenerateProperties(EntityMetadata metadata, string prefix) { foreach (var prop in metadata.Properties) { if (prop.IsRelation && !prop.IsCollection && prop.RelationMetadata != null) { foreach (var x in GenerateProperties(prop.RelationMetadata, prefix + prop.Name)) { yield return(x); } } else if (prop.IsCollection || prop.IsSimpleProperty) { TypeSyntax type = null; var identifier = prefix + prop.Name; if (prop.IsCollection) { type = (prop.RelatedEntityName + "DTO").ToCollectionType("IEnumerable"); } else { type = SyntaxFactory.IdentifierName(prop.Type); } yield return(SyntaxExtenders.DeclareAutoProperty(type, identifier)); } } }
private IEnumerable <PropertyDeclarationSyntax> GenerateProperties(EntityMetadata metadata, string prefix) { foreach (var prop in metadata.Properties) { if (prop.IsRelation && !prop.IsCollection && prop.RelationMetadata != null) { foreach (var x in GenerateProperties(prop.RelationMetadata, prefix + prop.Name)) { yield return(x); } } else if (prop.IsCollection || prop.IsSimpleProperty) { TypeSyntax type = null; var identifier = prefix + prop.Name; if (prop.IsCollection) { type = (prop.RelatedEntityName + "DTO").ToCollectionType("IEnumerable"); } else { type = SyntaxFactory.IdentifierName(prop.Type); } var result = SyntaxExtenders.DeclareAutoProperty(type, identifier); if (this._addDataContractAttrs) { result = result.WithAttributeLists(SyntaxExtenders.CreateAttributes("DataMember")); } else { result = result.WithAttributeLists(new SyntaxList <AttributeListSyntax>()); } if (this._addDataAnnotations && prop.AttributesList != null) { result = result.AddAttributeLists(prop.AttributesList.ToArray()); } yield return(result); } } }