예제 #1
0
 public void Update()
 {
     if (PrimaryId != null)
     {
         PrimaryId.Update();
     }
     UniqueIds.Update();
 }
예제 #2
0
        public EntityConstraints(Entity entity, XmlNode entityNode)
        {
            this.entity = entity;

            if (entity.HasSupertype)
            {
                primaryId = new PrimaryId(entity, entity.Supertype.Constraints.PrimaryId);
            }
            else
            {
                XmlNodeList pidNodes = entity.Model.QueryNode(entityNode, "./{0}:PrimaryId");
                if (pidNodes.Count > 1)
                {
                    throw new GlException("Primary identifier is declared more than once. {0}", entity);
                }
                else if (pidNodes.Count == 1)
                {
                    primaryId = new PrimaryId(entity, pidNodes[0]);
                }
                else                   // pidNodes.Count == 0
                {
                    primaryId = null;
                    foreach (Attribute a in entity.Attributes)
                    {
                        if (a.PrimaryId)
                        {
                            if (primaryId == null)
                            {
                                primaryId = new PrimaryId(entity, a);
                            }
                            else
                            {
                                primaryId.Attributes.Add(a);
                            }
                        }
                    }
                }
            }

            uniqueIds = new UniqueIdConstraints(entity, entityNode);
            foreach (Attribute a in entity.Attributes)
            {
                if (a.UniqueId)
                {
                    UniqueId uc = new UniqueId(entity, entity.Name);
                    uc.Attributes.Add(a);
                    uniqueIds.Add(uc);
                }
            }
        }
예제 #3
0
 public PrimaryId(Entity owner, PrimaryId source)
     : base(owner, source.Name)
 {
     foreach (Attribute a in source.Attributes)
     {
         Attribute target = owner.Attributes.GetByName(a.FullName);
         if (target == null)
         {
             throw new GlException("Cannot migrate primary id. Attribute \"{0}\" not found. Entity: {1}",
                                   a.FullName, owner.FullName);
         }
         Attributes.Add(target);
     }
     Init();
 }