From 9005ecfaa4661013190c451c02f3edcf7e84120c Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Sat, 25 Apr 2026 23:05:25 +0200 Subject: [PATCH 1/2] Add EntityAssociation to a few entities --- .../Cities/CityEntities.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Cities/CityEntities.cs b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Cities/CityEntities.cs index 4cac0d60c..a1ad02ab9 100644 --- a/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Cities/CityEntities.cs +++ b/src/Test/Desktop/OpenRiaServices.Common.DomainServices.Test/Cities/CityEntities.cs @@ -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 ZipCodesWithInfo { get; set; } } @@ -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 Counties { get; set; } } From 55735b72c1f7613da3da2aab83dbaddaead6b0a6 Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Sat, 25 Apr 2026 23:06:05 +0200 Subject: [PATCH 2/2] Fix EntityAssociationAttributeBuilder for single parameter (EntityAssociationAttribute) case --- .../EntityAssociationAttributeBuilder.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs b/src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs index da24db5e9..6e02447d2 100644 --- a/src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs +++ b/src/OpenRiaServices.Tools/Framework/MetadataPipeline/EntityAssociationAttributeBuilder.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; @@ -17,14 +18,14 @@ internal class EntityAssociationAttributeBuilder : ICustomAttributeBuilder public AttributeDeclaration GetAttributeDeclaration(Attribute attribute) { string name; - string[] thisKey, otherKey; + IReadOnlyList 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) @@ -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]);