Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

Expand All @@ -17,14 +18,14 @@ internal class EntityAssociationAttributeBuilder : ICustomAttributeBuilder
public AttributeDeclaration GetAttributeDeclaration(Attribute attribute)
{
string name;
string[] thisKey, otherKey;
IReadOnlyList<string> thisKey, otherKey;
bool isForeignKey;

if (attribute is EntityAssociationAttribute entityAssociation)
{
name = entityAssociation.Name;
thisKey = (string[])entityAssociation.ThisKeyMembers;
otherKey = (string[])entityAssociation.OtherKeyMembers;
thisKey = entityAssociation.ThisKeyMembers;
otherKey = entityAssociation.OtherKeyMembers;
isForeignKey = entityAssociation.IsForeignKey;
}
else if (attribute is AssociationAttribute associationAttribute)
Expand All @@ -43,7 +44,7 @@ public AttributeDeclaration GetAttributeDeclaration(Attribute attribute)
// If there is only a single key member, we use string based constructor
AttributeDeclaration attributeDeclaration = new AttributeDeclaration(typeof(EntityAssociationAttribute));
attributeDeclaration.ConstructorArguments.Add(name);
if (thisKey.Length == 1 && otherKey.Length == 1)
if (thisKey.Count == 1 && otherKey.Count == 1)
{
attributeDeclaration.ConstructorArguments.Add(thisKey[0]);
attributeDeclaration.ConstructorArguments.Add(otherKey[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public partial class CityWithInfoMetadata
[StringLength(32)]
public string Info { get; set; }

[Association("CityWithInfo_ZipWithInfo", "Name, CountyName, StateName", "CityName, CountyName, StateName")]
[EntityAssociation("CityWithInfo_ZipWithInfo", ["Name", "CountyName", "StateName"], ["CityName", "CountyName", "StateName"])]
public List<ZipWithInfo> ZipCodesWithInfo { get; set; }
}

Expand Down Expand Up @@ -132,7 +132,7 @@ public partial class StateMetadata
[RoundtripOriginal]
public string FullName { get; set; }

[Association("State_County", "Name", "StateName")]
[EntityAssociation("State_County", "Name", "StateName")]
[CustomValidation(typeof(CountiesValidator), "AreCountiesValid")]
public List<County> Counties { get; set; }
}
Expand Down
Loading