public CodeAttributeDeclaration GetHasManyAttribute() { CodeAttributeDeclaration attribute = new CodeAttributeDeclaration("HasMany"); attribute.Arguments.Add(AttributeHelper.GetPrimitiveTypeAttributeArgument(CodeGenerationContext.GetTypeDeclaration(Source).Name)); if (TargetAccess != PropertyAccess.Property) { attribute.Arguments.Add(AttributeHelper.GetNamedEnumAttributeArgument("Access", "PropertyAccess", TargetAccess)); } if (TargetCache != CacheEnum.Undefined) { attribute.Arguments.Add(AttributeHelper.GetNamedEnumAttributeArgument("Cache", "CacheEnum", TargetCache)); } if (TargetCascade != ManyRelationCascadeEnum.None) { attribute.Arguments.Add(AttributeHelper.GetNamedEnumAttributeArgument("Cascade", "ManyRelationCascadeEnum", TargetCascade)); } if (!string.IsNullOrEmpty(TargetColumnKey)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("ColumnKey", TargetColumnKey)); } if (!string.IsNullOrEmpty(TargetCustomAccess)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("CustomAccess", TargetCustomAccess)); } if (TargetRelationType == RelationType.Map) { // TODO: Index & IndexType ? } if (TargetInverse) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Inverse", TargetInverse)); } if (TargetLazy) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Lazy", TargetLazy)); } if (TargetFetch != FetchEnum.Unspecified) { attribute.Arguments.Add(AttributeHelper.GetNamedEnumAttributeArgument("Fetch", "FetchEnum", TargetFetch)); } if (!string.IsNullOrEmpty(TargetMapType)) { attribute.Arguments.Add(AttributeHelper.GetNamedTypeAttributeArgument("MapType", TargetMapType)); } if (!string.IsNullOrEmpty(TargetOrderBy)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("OrderBy", TargetOrderBy)); } if (TargetRelationType != RelationType.Guess) { attribute.Arguments.Add( AttributeHelper.GetNamedEnumAttributeArgument("RelationType", "RelationType", TargetRelationType)); } if (!string.IsNullOrEmpty(TargetSchema)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Schema", TargetSchema)); } if (TargetRelationType == RelationType.Set && !string.IsNullOrEmpty(TargetSort)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Sort", TargetSort)); } if (!string.IsNullOrEmpty(TargetTable)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Table", TargetTable)); } if (!string.IsNullOrEmpty(TargetWhere)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Where", TargetWhere)); } if (TargetNotFoundBehaviour != NotFoundBehaviour.Default) { attribute.Arguments.Add( AttributeHelper.GetNamedEnumAttributeArgument("NotFoundBehaviour", "NotFoundBehaviour", TargetNotFoundBehaviour)); } if (!string.IsNullOrEmpty(TargetIndexType)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("IndexType", TargetIndexType)); } if (!string.IsNullOrEmpty(TargetIndex)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Index", TargetIndex)); } if (!string.IsNullOrEmpty(TargetElement)) { attribute.Arguments.Add(AttributeHelper.GetNamedAttributeArgument("Element", TargetElement)); } return(attribute); }