/// <inheritdoc /> public virtual string GetMethodChain(CodeHelper code) { Debug.Assert(code != null, "code is null."); Debug.Assert(_properties.Count != 0, "_properties is empty."); return(".HasForeignKey(" + code.Lambda(_properties) + ")"); }
/// <inheritdoc /> public virtual string GetMethodChain(CodeHelper code) { // TODO: Throw instead? Debug.Assert(code != null, "code is null."); Debug.Assert(_keyProperties.Count != 0, "_keyProperties is empty."); return(".HasKey(" + code.Lambda(_keyProperties) + ")"); }
/// <inheritdoc /> // TODO: Handle formatting elsewhere public virtual string GetMethodChain(CodeHelper code) { Debug.Assert(code != null, "code is null."); Debug.Assert(LeftEntityType != null, "LeftEntityType is null."); Debug.Assert(LeftNavigationProperty != null, "LeftNavigationProperty is null."); Debug.Assert(RightNavigationProperty != null, "RightNavigationProperty is null."); var builder = new StringBuilder(); builder.Append(".Entity"); builder.Append(code.TypeArgument(code.Type(LeftEntityType))); builder.AppendLine("()"); var rightMultiplicity = RightNavigationProperty.FromEndMember.RelationshipMultiplicity; switch (rightMultiplicity) { case RelationshipMultiplicity.Many: builder.Append(" .HasMany("); builder.Append(code.Lambda(LeftNavigationProperty)); builder.Append(")"); break; case RelationshipMultiplicity.One: builder.Append(" .HasRequired("); builder.Append(code.Lambda(LeftNavigationProperty)); builder.Append(")"); break; case RelationshipMultiplicity.ZeroOrOne: builder.Append(" .HasOptional("); builder.Append(code.Lambda(LeftNavigationProperty)); builder.Append(")"); break; default: Debug.Fail("rightMultiplicity is not a valid RelationshipMultiplicity value."); break; } builder.AppendLine(); switch (LeftNavigationProperty.FromEndMember.RelationshipMultiplicity) { case RelationshipMultiplicity.Many: builder.Append(" .WithMany("); builder.Append(code.Lambda(RightNavigationProperty)); builder.Append(")"); break; case RelationshipMultiplicity.One: Debug.Assert(rightMultiplicity != RelationshipMultiplicity.One, "rightMultiplicity is One."); builder.Append(" .WithRequired("); builder.Append(code.Lambda(RightNavigationProperty)); builder.Append(")"); break; case RelationshipMultiplicity.ZeroOrOne: Debug.Assert( rightMultiplicity != RelationshipMultiplicity.ZeroOrOne, "rightMultiplicity is ZeroOrOne."); builder.Append(" .WithOptional("); builder.Append(code.Lambda(RightNavigationProperty)); builder.Append(")"); break; default: Debug.Fail("LeftNavigationProperty.FromEndMember.RelationshipMultiplicity is not a valid RelationshipMultiplicity value."); break; } return(builder.ToString()); }