コード例 #1
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);
                }
            }
        }
コード例 #2
0
 public EntityConstraints(Entity entity)
 {
     uniqueIds = new UniqueIdConstraints(entity);
 }