public override string PropertyBefore(IAssociationEnd associationEnd) { if (!associationEnd.IsNavigable) { return(base.PropertyBefore(associationEnd)); } var t = ClassTypeSource.InProject(Template.Project, DomainEntityInterfaceTemplate.Identifier, nameof(IEnumerable)); return($@" {t.GetClassType(associationEnd)} {associationEnd.Name().ToPascalCase()} {{ get; }} "); }
public override string AssociationAfter(IAssociationEnd associationEnd) { if (!associationEnd.IsNavigable) { return(base.AssociationBefore(associationEnd)); } var t = ClassTypeSource.InProject(Template.Project, DomainEntityInterfaceTemplate.Identifier, nameof(IEnumerable)); return($@" {t.GetClassType(associationEnd)} I{associationEnd.OtherEnd().Class.Name}.{associationEnd.Name().ToPascalCase()} => {associationEnd.Name().ToPascalCase()}; "); }
public override string AssociationBefore(IAssociationEnd associationEnd) { if (!associationEnd.IsNavigable && associationEnd.Multiplicity == Multiplicity.One && associationEnd.OtherEnd().Multiplicity == Multiplicity.Many) { return($@" public virtual { Template.Types.Get(associationEnd) } { associationEnd.Name() } {{ get; set; }} "); } return(base.AssociationBefore(associationEnd)); }
public void MapOneToOne(IAssociationEnd associationEnd) { var parent = associationEnd.Association.SourceEnd; var child = associationEnd.Association.TargetEnd; string hasClause = associationEnd.MinMultiplicity != "0" ? "HasRequired" : "HasOptional"; string withClause = "With" + (associationEnd.OtherEnd().MinMultiplicity != "0" ? "Required" : "Optional") + ((associationEnd.MinMultiplicity != "0") == (associationEnd.OtherEnd().MinMultiplicity != "0") ? DeterminePrinciple(associationEnd) : ""); #line default #line hidden #line 207 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" "); #line default #line hidden #line 208 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\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 208 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\r\n "); #line default #line hidden #line 209 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\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 209 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\r\n"); #line default #line hidden #line 210 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\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") ) { #line default #line hidden #line 213 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" .Map(m => m.MapKey(\""); #line default #line hidden #line 214 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(associationEnd.Name().ToPascalCase() + "Id")); #line default #line hidden #line 214 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\"))\r\n"); #line default #line hidden #line 215 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" } #line default #line hidden #line 215 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" ;\r\n"); #line default #line hidden #line 217 "C:\Dev\Intent\IntentArchitect\Modules\Intent.Modules.EF\Templates\EFMapping\EFMappingTemplate.tt" }
public void MapOneToOne(IAssociationEnd associationEnd) { var parent = associationEnd.Association.SourceEnd; var child = associationEnd.Association.TargetEnd; string hasClause = associationEnd.MinMultiplicity != "0" ? "HasRequired" : "HasOptional"; string withClause = "With" + (associationEnd.OtherEnd().MinMultiplicity != "0" ? "Required" : "Optional") + ((associationEnd.MinMultiplicity != "0") == (associationEnd.OtherEnd().MinMultiplicity != "0") ? DeterminePrinciple(associationEnd) : ""); #line default #line hidden #line 232 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" "); #line default #line hidden #line 233 "C:\Dev\Intent.Modules\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 233 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\r\n "); #line default #line hidden #line 234 "C:\Dev\Intent.Modules\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 234 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\r\n"); #line default #line hidden #line 235 "C:\Dev\Intent.Modules\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().GetStereotypeProperty("Foreign Key", "Column Name", associationEnd.Name().ToPascalCase() + "Id").ToPascalCase())) { #line default #line hidden #line 238 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" .Map(m => m.MapKey(\""); #line default #line hidden #line 239 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(associationEnd.OtherEnd().GetStereotypeProperty("Foreign Key", "Column Name", associationEnd.Name().ToPascalCase() + "Id"))); #line default #line hidden #line 239 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\"))\r\n"); #line default #line hidden #line 240 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" } #line default #line hidden #line 241 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" if (associationEnd.Association.AssociationType == AssociationType.Composition) { #line default #line hidden #line 241 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write("\t\t\t.WillCascadeOnDelete()\r\n"); #line default #line hidden #line 243 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" } #line default #line hidden #line 243 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" this.Write(" ;\r\n"); #line default #line hidden #line 245 "C:\Dev\Intent.Modules\Modules\Intent.Modules.EntityFramework\Templates\EFMapping\EFMappingTemplate.tt" }
public override string PropertyBefore(IAssociationEnd associationEnd) { if (associationEnd.RequiresForeignKey()) { if (associationEnd.OtherEnd().HasStereotype("Foreign Key")) { return(base.PropertyBefore(associationEnd)); } return($@" {_foreignKeyType}{ (associationEnd.IsNullable ? "?" : "") } { associationEnd.Name().ToPascalCase() }Id {{ get; }} "); } return(base.PropertyBefore(associationEnd)); }