public string GetAssociationReturn(AssociationEnd association) { if (association.IsCollection()) { return(String.Format("{0} ?? ({0} = new {1}())", association.Name().ToPrivateMember(), association.ConstructorType())); } return(association.Name().ToPrivateMember()); }
public void AddCheckConstraint(AssociationEnd associationEnd) { string checkFunc = null; if (associationEnd.MaxMultiplicity == "1" && associationEnd.MinMultiplicity == "1") { checkFunc = associationEnd.Name().ToPascalCase() + " != null"; } else if (associationEnd.MaxMultiplicity == "*") { checkFunc = associationEnd.Name().ToPascalCase() + ".Count >= " + associationEnd.MinMultiplicity; } else { checkFunc = string.Format("{0}.Count >= {1} && {0}.Count <= {2}", associationEnd.Name().ToPascalCase(), associationEnd.MinMultiplicity, associationEnd.MaxMultiplicity); } #line default #line hidden #line 157 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" this.Write(" RequiredMultiplcityChecks[\""); #line default #line hidden #line 158 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(associationEnd.Name().ToPascalCase())); #line default #line hidden #line 158 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" this.Write("\"] = () => "); #line default #line hidden #line 158 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" this.Write(this.ToStringHelper.ToStringWithCulture(checkFunc)); #line default #line hidden #line 158 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" this.Write(" ;\r\n"); #line default #line hidden #line 159 "C:\Dev\Intent.Modules\Modules\Intent.Modules.RichDomain\Templates\EntityState\DomainEntityStateTemplate.tt" }
public bool MustCreateForeignKeyPropertyIfApplicable(AssociationEnd associationEnd, out string identifierType, out string propertyName) { identifierType = ""; propertyName = ""; if (associationEnd.RelationshipType == RelationshipType.OneToMany) { var otherClass = associationEnd.Class; identifierType = GetEntityIdTypeName(otherClass); propertyName = associationEnd.Name().ToPascalCase() + "Id"; return(true); } return(false); }
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" }
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); }