public string CreateForeignKeyPropertyIfApplicable(AssociationEnd association)
        {
            if (association.RelationshipType == RelationshipType.OneToMany)
            {
                return(string.Format("public Guid{0} {1}Id ", association.IsMandatory() ? "" : "?", association.Name().ToPascalCase()) + "{ get; set; }");
            }

            return(String.Empty);
        }
예제 #2
0
        public void MapOneToOne(AssociationEnd associationEnd)
        {
            AssociationEnd parent = associationEnd.Association.ParentEnd;
            AssociationEnd child  = associationEnd.Association.ChildEnd;

            string hasClause  = associationEnd.IsMandatory() ? "HasRequired" : "HasOptional";
            string withClause = "With" + (associationEnd.OtherAssociationEnd().IsMandatory() ? "Required" : "Optional") + (associationEnd.IsMandatory() == associationEnd.OtherAssociationEnd().IsMandatory() ?  DeterminePrinciple(associationEnd)  : "");


        #line default
        #line hidden

        #line 244 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write("            ");


        #line default
        #line hidden

        #line 245 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Format("this.{0}(x => x.{1})", hasClause, associationEnd.Name().ToPascalCase())));


        #line default
        #line hidden

        #line 245 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write("\r\n            ");


        #line default
        #line hidden

        #line 246 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Format(".{0}({1})", withClause, associationEnd.OtherAssociationEnd().Navigable ? "x => x." + associationEnd.OtherAssociationEnd().Name().ToPascalCase(): "")));


        #line default
        #line hidden

        #line 246 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write("\r\n");


        #line default
        #line hidden

        #line 247 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            if ((associationEnd.Association.AssociationType == AssociationType.Composite && associationEnd.Association.RelationshipString() == "0..1->1") ||
                (associationEnd.Association.AssociationType == AssociationType.Aggregation && associationEnd.Association.RelationshipString() == "0..1->1")
                )
            {
        #line default
        #line hidden

        #line 250 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
                this.Write("            .Map(m => m.MapKey(\"");


        #line default
        #line hidden

        #line 251 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(associationEnd.Name().ToPascalCase() + "Id"));


        #line default
        #line hidden

        #line 251 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
                this.Write("\"))\r\n");


        #line default
        #line hidden

        #line 252 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            }

        #line default
        #line hidden

        #line 252 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write("            ;\r\n");


        #line default
        #line hidden

        #line 254 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
        }