コード例 #1
0
        private AssociationEnd CreateStorageAssociationEnd(IEntity entity, string role, LinqToEdmx.Model.Storage.Association assocication, bool isCascadeDelete)
        {
            //  <End Role="Category" Type="PetShopModel1.Store.Category" Multiplicity="1">
            //     <OnDelete Action="Cascade" />
            //  </End>
            //  <End Role="Product" Type="PetShopModel1.Store.Product" Multiplicity="*" />
            var end = new AssociationEnd() {
                Role = role,
                Type = String.Concat(StorageSchema.Namespace, ".", entity.EntityKeyName)
            };

            if (isCascadeDelete) {
                end.OnDelete.Add(new OnAction() {
                    Action = EdmxConstants.OnDeleteActionCascade
                });
            }

            assocication.Ends.Add(end);

            return end;
        }
コード例 #2
0
 private static void UpdateStorageAssociationEndMultiplicity(IAssociation association, AssociationEnd principalEnd, AssociationEnd dependentEnd)
 {
     switch (association.AssociationType) {
         case AssociationType.OneToMany:
             principalEnd.Multiplicity = MultiplicityConstants.One;
             dependentEnd.Multiplicity = MultiplicityConstants.Many;
             break;
         case AssociationType.OneToOne:
             principalEnd.Multiplicity = MultiplicityConstants.One;
             dependentEnd.Multiplicity = MultiplicityConstants.One;
             break;
         case AssociationType.OneToZeroOrOne:
             principalEnd.Multiplicity = MultiplicityConstants.One;
             dependentEnd.Multiplicity = MultiplicityConstants.ZeroToOne;
             break;
         case AssociationType.ZeroOrOneToMany:
         case AssociationType.ManyToZeroOrOne:
             principalEnd.Multiplicity = MultiplicityConstants.ZeroToOne;
             dependentEnd.Multiplicity = MultiplicityConstants.Many;
             break;
         default:
             principalEnd.Multiplicity = MultiplicityConstants.One;
             dependentEnd.Multiplicity = MultiplicityConstants.Many;
             break;
     }
 }