public override string AssociationAfter(AssociationEndModel associationEnd)
        {
            if (!associationEnd.IsNavigable)
            {
                return(base.AssociationAfter(associationEnd));
            }

            var name = Template.Types.InContext(DomainEntityStateTemplate.InterfaceContext).Get(associationEnd).Name;

            return($@"
        {Template.NormalizeNamespace(name)} I{associationEnd.OtherEnd().Class.Name}.{associationEnd.Name().ToPascalCase()} => {associationEnd.Name().ToPascalCase()};
");
        }
예제 #2
0
        public override string PropertyBefore(AssociationEndModel associationEnd)
        {
            if (associationEnd.RequiresForeignKey())
            {
                if (associationEnd.OtherEnd().Element.HasStereotype("Foreign Key"))
                {
                    return(base.PropertyBefore(associationEnd));
                }

                var foreignKeyType = associationEnd.Class.GetSurrogateKeyType(Template.Types) ?? Template.UseType(_foreignKeyType);
                return($@"
{foreignKeyType}{ (associationEnd.IsNullable ? "?" : "") } { associationEnd.Name().ToPascalCase() }Id {{ get; }}");
            }
            return(base.PropertyBefore(associationEnd));
        }
예제 #3
0
        public override string AssociationBefore(AssociationEndModel associationEnd)
        {
            if (!associationEnd.IsNavigable && associationEnd.Multiplicity == Multiplicity.One && associationEnd.OtherEnd().Multiplicity == Multiplicity.Many)
            {
                return($@"       public virtual { Template.GetTypeName(associationEnd) } { associationEnd.Name() } {{ get; set; }}
");
            }
            if (!associationEnd.IsNavigable && associationEnd.Multiplicity == Multiplicity.Many && associationEnd.OtherEnd().Multiplicity == Multiplicity.Many)
            {
                return($@"       public virtual { Template.GetTypeName(associationEnd) } { associationEnd.Name() } {{ get; set; }}
");
            }
            return(base.AssociationBefore(associationEnd));
        }
예제 #4
0
        public void MapOneToOne(AssociationEndModel associationEnd)
        {
            var parent = associationEnd.Association.SourceEnd;
            var child  = associationEnd.Association.TargetEnd;

            string hasClause  = !associationEnd.IsNullable ? "HasRequired" : "HasOptional";
            string withClause = "With" + (!associationEnd.OtherEnd().IsNullable ? "Required" : "Optional") + ((!associationEnd.IsNullable) == (!associationEnd.OtherEnd().IsNullable) ?  DeterminePrinciple(associationEnd)  : "");


        #line default
        #line hidden

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


        #line default
        #line hidden

        #line 226 "C:\Dev\Intent.Modules.NET\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 226 "C:\Dev\Intent.Modules.NET\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            this.Write("\r\n            ");


        #line default
        #line hidden

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


        #line default
        #line hidden

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


        #line default
        #line hidden

        #line 228 "C:\Dev\Intent.Modules.NET\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            if (((associationEnd.Association.AssociationType == AssociationType.Composition && associationEnd.Association.RelationshipString() == "0..1->1") ||
                 (associationEnd.Association.AssociationType == AssociationType.Aggregation && associationEnd.Association.RelationshipString() == "0..1->1")) &&
                Model.Attributes.All(a => a.Name.ToPascalCase() != associationEnd.OtherEnd().Class.GetStereotypeProperty("Foreign Key", "Column Name", associationEnd.Name().ToPascalCase() + "Id").ToPascalCase()))
            {
        #line default
        #line hidden

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


        #line default
        #line hidden

        #line 232 "C:\Dev\Intent.Modules.NET\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(associationEnd.OtherEnd().Class.GetStereotypeProperty("Foreign Key", "Column Name", associationEnd.Name().ToPascalCase() + "Id")));


        #line default
        #line hidden

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


        #line default
        #line hidden

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

        #line default
        #line hidden

        #line 234 "C:\Dev\Intent.Modules.NET\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt"
            if (associationEnd.Association.AssociationType == AssociationType.Composition)
            {
        #line default
        #line hidden

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


        #line default
        #line hidden

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

        #line default
        #line hidden

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


        #line default
        #line hidden

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