Esempio n. 1
0
        private void BindPersistentClassCommonValues(IEntityMapping classMapping, PersistentClass model, IDictionary <string, MetaAttribute> inheritedMetas)
        {
            // DISCRIMINATOR
            var discriminable = classMapping as IEntityDiscriminableMapping;

            model.DiscriminatorValue = (discriminable == null || string.IsNullOrEmpty(discriminable.DiscriminatorValue)) ? model.EntityName : discriminable.DiscriminatorValue;

            // DYNAMIC UPDATE
            model.DynamicUpdate = classMapping.DynamicUpdate;

            // DYNAMIC INSERT
            model.DynamicInsert = classMapping.DynamicInsert;

            // IMPORT
            // For entities, the EntityName is the key to find a persister
            // NH Different behavior: we are using the association between EntityName and its more certain implementation (AssemblyQualifiedName)
            // Dynamic entities have no class, reverts to EntityName. -AK
            string qualifiedName = model.MappedClass == null ? model.EntityName : model.MappedClass.AssemblyQualifiedName;

            mappings.AddImport(qualifiedName, model.EntityName);
            if (mappings.IsAutoImport && model.EntityName.IndexOf('.') > 0)
            {
                mappings.AddImport(qualifiedName, StringHelper.Unqualify(model.EntityName));
            }

            // BATCH SIZE
            if (classMapping.BatchSize.HasValue)
            {
                model.BatchSize = classMapping.BatchSize.Value;
            }

            // SELECT BEFORE UPDATE
            model.SelectBeforeUpdate = classMapping.SelectBeforeUpdate;

            // META ATTRIBUTES
            model.MetaAttributes = GetMetas(classMapping, inheritedMetas);

            // PERSISTER
            if (!string.IsNullOrEmpty(classMapping.Persister))
            {
                model.EntityPersisterClass = ClassForNameChecked(classMapping.Persister, mappings,
                                                                 "could not instantiate persister class: {0}");
            }

            // CUSTOM SQL
            HandleCustomSQL(classMapping, model);
            if (classMapping.SqlLoader != null)
            {
                model.LoaderName = classMapping.SqlLoader.queryref;
            }

            foreach (var synchronize in classMapping.Synchronize)
            {
                model.AddSynchronizedTable(synchronize.table);
            }

            model.IsAbstract = classMapping.IsAbstract;
        }