Пример #1
0
        private void LoadCompositeKey()
        {
            var compositeKey = EntitySource.Root.Descendant("composite-id", XmlNamespace);

            if (compositeKey == null)
            {
                return;
            }

            var keys = compositeKey.Descendants("key-property", XmlNamespace);

            foreach (var key in keys)
            {
                var property = new NHibernateProperty(key, this);
                Key.Properties.Add(property);
            }

            var foreignKeys = compositeKey.Descendants("key-many-to-one", XmlNamespace);

            foreach (var foreignKey in foreignKeys)
            {
                var association = NHibernateAssociation.FromElement(this, foreignKey, foreignKey, AssociationType.ManyToOne, XmlNamespace);
                if (association != null)
                {
                    if (!AssociationMap.ContainsKey(association.Name))
                    {
                        AssociationMap.Add(association.Name, association);
                    }

                    Key.Associations.Add(association);
                }
            }
        }
Пример #2
0
        private void LoadKey()
        {
            var key = EntitySource.Root.Descendant("id", XmlNamespace);

            if (key == null)
            {
                return;
            }

            var property = new NHibernateProperty(key, this);

            Key.Properties.Add(property);
        }
Пример #3
0
        protected override void LoadProperties()
        {
            var properties = EntitySource.Root
                             .Descendants("property", XmlNamespace)
                             .ToList();

            var version = EntitySource.Root.Descendant("version", XmlNamespace);

            if (version != null)
            {
                properties.Add(version);
            }

            foreach (var prop in properties)
            {
                var propName = prop.Attribute("name");
                if (propName == null)
                {
                    continue;
                }

                if (Configuration.Instance.ExcludeRegexIsMatch(propName.Value) || PropertyMap.ContainsKey(propName.Value))
                {
                    continue;
                }

                var property = new NHibernateProperty(prop, this);
                if (!PropertyMap.ContainsKey(property.Name))
                {
                    PropertyMap.Add(property.Name, property);
                }
            }

            if (PropertyMap.Values.Count(em => em.IsType(PropertyType.Concurrency)) > 1)
            {
                throw new Exception(String.Format("More than one Concurrency property in {0}", EntityKeyName));
            }
        }