private void IssueManyToManyWarning(IAssociationEnd associationEnd) { Logging.Log.Warning($@"Intent.EntityFrameworkCore: Cannot create mapping relationship from {Model.Name} to {associationEnd.Class.Name}. It has been ignored, and will not be persisted. Many-to-Many relationships are not yet supported by EntityFrameworkCore as yet. You will need to create a joining-table entity (e.g. [{Model.Name}] 1 --> * [{Model.Name}{associationEnd.Class.Name}] * --> 1 [{associationEnd.Class.Name}]) For more information, please see https://github.com/aspnet/EntityFrameworkCore/issues/1368"); }
public string CollectionInitializer(IAssociationEnd associatedClass, string memberName) { if (associatedClass.Multiplicity == Multiplicity.Many) { return(String.Format(" ?? ({0} = new List<{1}>())", memberName, associatedClass.Class.Name + "")); } return(string.Empty); }
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 static string IdentifierName(this IAssociationEnd associationEnd) { if (string.IsNullOrEmpty(associationEnd.Name)) { return(associationEnd.Class.IdentifierType()); } else { return(associationEnd.Name.ToPascalCase() + "Id"); } }
public string DeterminePrinciple(IAssociationEnd associationEnd) { if (associationEnd.Association.AssociationType == AssociationType.Composition) { return("Principal"); } if (associationEnd.Association.AssociationType == AssociationType.Aggregation) { return("Dependent"); } return(""); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.ReferredAssociationEnds == null)) { IAssociationEnd referredAssociationEndsCasted = item.As <IAssociationEnd>(); if ((referredAssociationEndsCasted != null)) { this._parent.ReferredAssociationEnds = referredAssociationEndsCasted; return; } } }
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 static string MultiplicityString(this IAssociationEnd associationEnd) { if (associationEnd.MaxMultiplicity == "*") { return("*"); } if (associationEnd.MaxMultiplicity == associationEnd.MinMultiplicity) { return(associationEnd.MinMultiplicity); } return(associationEnd.MinMultiplicity + ".." + associationEnd.MaxMultiplicity); }
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)); }
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()}; "); }
private string GetForeignKeyLambda(IAssociationEnd associationEnd) { var columns = associationEnd.GetStereotypeProperty("Foreign Key", "Column Name", associationEnd.OtherEnd().Name().ToPascalCase() + "Id") .Split(',') .Select(x => x.Trim()) .ToList(); if (columns.Count() == 1) { return($"x => x.{columns.Single()}"); } return($"x => new {{ {string.Join(", ", columns.Select(x => "x."+ x))}}}"); }
public static string Name(this IAssociationEnd associationEnd) { if (string.IsNullOrEmpty(associationEnd.Name)) { var className = associationEnd.Class.Name; if (associationEnd.MaxMultiplicity == "*" || int.Parse(associationEnd.MaxMultiplicity) > 1) { return(className.EndsWith("y") ? className.Substring(0, className.Length - 1) + "ies" : string.Format("{0}s", className)); } return(associationEnd.Class.Name); } return(associationEnd.Name); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IAssociationEnd endsCasted = item.As <IAssociationEnd>(); if ((endsCasted != null)) { this._parent.Ends.Add(endsCasted); } TTC2021.OclToSql.Ocl.Dm.IAttribute attributesCasted = item.As <TTC2021.OclToSql.Ocl.Dm.IAttribute>(); if ((attributesCasted != null)) { this._parent.Attributes.Add(attributesCasted); } }
public static string GetPropertyName(this IAssociationEnd associationEnd) { if (string.IsNullOrEmpty(associationEnd.Name)) { var className = associationEnd.Class.Name; if (associationEnd.Multiplicity == Multiplicity.Many) { return(className.Pluralize(false)); } return(className); } return(associationEnd.Name); }
public string GetAssociationType(IAssociationEnd associationEnd, bool readOnly = false) { if (associationEnd.Multiplicity == Multiplicity.Many) { if (readOnly) { return("IEnumerable<" + associationEnd.Class.Name + ">"); } else { return("ICollection<" + associationEnd.Class.Name + ">"); } } return(associationEnd.Class.Name); }
public static string Type(this IAssociationEnd associationEnd, string prefix, string suffix, bool readOnly) { if (associationEnd.Multiplicity == Multiplicity.Many) { if (readOnly) { return("IEnumerable<" + prefix + associationEnd.Class.Name + suffix + ">"); } else { return("ICollection<" + prefix + associationEnd.Class.Name + suffix + ">"); } } return(prefix + associationEnd.Class.Name + suffix); }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IAssociationEnd associationEndItem = item.As <IAssociationEnd>(); if (((associationEndItem != null) && this._parent.Ends.Remove(associationEndItem))) { return(true); } TTC2021.OclToSql.Ocl.Dm.IAttribute attributeItem = item.As <TTC2021.OclToSql.Ocl.Dm.IAttribute>(); if (((attributeItem != null) && this._parent.Attributes.Remove(attributeItem))) { return(true); } return(false); }
public static RelationshipType Relationship(this IAssociationEnd associationEnd) { if ((associationEnd.Multiplicity == Multiplicity.One || associationEnd.Multiplicity == Multiplicity.ZeroToOne) && (associationEnd.OtherEnd().Multiplicity == Multiplicity.One || associationEnd.OtherEnd().Multiplicity == Multiplicity.ZeroToOne)) { return(RelationshipType.OneToOne); } if ((associationEnd.Multiplicity == Multiplicity.One || associationEnd.Multiplicity == Multiplicity.ZeroToOne) && associationEnd.OtherEnd().Multiplicity == Multiplicity.Many) { return(RelationshipType.OneToMany); } if (associationEnd.Multiplicity == Multiplicity.Many && (associationEnd.OtherEnd().Multiplicity == Multiplicity.One || associationEnd.OtherEnd().Multiplicity == Multiplicity.ZeroToOne)) { return(RelationshipType.ManyToOne); } if (associationEnd.Multiplicity == Multiplicity.Many && associationEnd.OtherEnd().Multiplicity == Multiplicity.Many) { return(RelationshipType.ManyToMany); } throw new Exception(string.Format("The relationship type from [{0}] to [{1}] could not be determined.", associationEnd.Class.Name, associationEnd.OtherEnd().Class.Name)); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Target == null)) { IEntity targetCasted = item.As <IEntity>(); if ((targetCasted != null)) { this._parent.Target = targetCasted; return; } } if ((this._parent.Opp == null)) { IAssociationEnd oppCasted = item.As <IAssociationEnd>(); if ((oppCasted != null)) { this._parent.Opp = oppCasted; return; } } }
public virtual bool CanWriteDefaultAssociation(IAssociationEnd association) { return(true); }
public virtual string AssociationAfter(IAssociationEnd associationEnd) { return(null); }
public virtual string AssociationBefore(IAssociationEnd associationEnd) { return(null); }
public virtual string PropertySetterAfter(IAssociationEnd associationEnd) { return(null); }
public virtual string PropertyAnnotations(IAssociationEnd associationEnd) { return(null); }
public AssociationEndModel(IAssociationEnd associationEnd, AssociationModel association) { _associationEnd = associationEnd; _association = association; }
public static AssociationModel CreateFromEnd(IAssociationEnd associationEnd) { var association = new AssociationModel(associationEnd.Association); return(association); }
public AssociationTargetEndModel(IAssociationEnd associationEnd, AssociationModel association) : base(associationEnd, association) { }
public AssociationSourceEndModel(IAssociationEnd associationEnd, AssociationModel association) : base(associationEnd, association) { }
public GeneralizationEndModel(IAssociationEnd associationEnd, GeneralizationModel association) { _associationEnd = associationEnd; _association = association; }
public GeneralizationTargetEndModel(IAssociationEnd associationEnd, GeneralizationModel association) : base(associationEnd, association) { }