Esempio n. 1
0
 public void PrimaryKeyConvention(Type type, IClassAttributesMapper map)
 {
     map.Id(k =>
     {
         k.Generator(Generators.Native);
         k.Column("Id");
     });
 }
Esempio n. 2
0
 public static void PrimaryKeyConvention(Type type, IClassAttributesMapper map)
 {
     map.Id(k =>
     {
         k.Generator(Generators.Native);
         k.Column(type.Name + "Id");
     });
 }
Esempio n. 3
0
        void ApplyClassConvention(IModelInspector mi, Type type, IClassAttributesMapper map)
        {
            if (!sagaEntities.Contains(type))
            {
                map.Id(idMapper => idMapper.Generator(Generators.GuidComb));
            }
            else
            {
                map.Id(idMapper => idMapper.Generator(Generators.Assigned));
            }

            var rowVersionProperty = type.GetProperties()
                                     .Where(HasAttribute <RowVersionAttribute>)
                                     .FirstOrDefault();

            if (rowVersionProperty != null)
            {
                map.Version(rowVersionProperty, mapper =>
                {
                    mapper.Generated(VersionGeneration.Never);

                    if (rowVersionProperty.PropertyType == typeof(DateTime))
                    {
                        mapper.Type(new TimestampType());
                    }

                    if (rowVersionProperty.PropertyType == typeof(byte[]))
                    {
                        mapper.Type(new BinaryBlobType());
                        mapper.Generated(VersionGeneration.Always);
                        mapper.UnsavedValue(null);
                        mapper.Column(cm =>
                        {
                            cm.NotNullable(false);
                            cm.SqlType(NHibernateUtil.Timestamp.Name);
                        });
                    }
                });
            }

            var tableAttribute = GetAttribute <TableNameAttribute>(type);

            if (tableAttribute != null)
            {
                map.Table(tableAttribute.TableName);
                if (!String.IsNullOrEmpty(tableAttribute.Schema))
                {
                    map.Schema(tableAttribute.Schema);
                }

                return;
            }

            var namingConvention = tableNamingConvention(type);

            map.Table(namingConvention);
        }
        protected virtual void NoPoidGuid(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = PoidPropertyOrField(modelInspector, type);

            if (ReferenceEquals(null, poidPropertyOrField))
            {
                classCustomizer.Id(null, idm => idm.Generator(Generators.Guid));
            }
        }
 protected void BeforeMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
     classCustomizer.Lazy(true);
     classCustomizer.Table(this.GetNormalizedDbName(type.Name));
     classCustomizer.Id(type.GetProperty(String.Concat(type.Name, "Id")), map =>
     {
         map.Column(this.GetNormalizedDbName(String.Concat(type.Name, "ID")));
         map.Generator(new HighLowGeneratorDef());
     });
 }
 private void ConfigureDiscriminatorColumn(
     IModelInspector modelInspector, System.Type type,
     IClassAttributesMapper classCustomizer)
 {
     if (modelInspector.IsTablePerClassHierarchy(type))
     {
         classCustomizer.Discriminator(x =>
                                       x.Column(type.Name + "Type"));
     }
 }
 public static void AutoMapper_BeforeMapClass(IModelInspector modelInspector, Type type,
                                              IClassAttributesMapper classCustomizer)
 {
     classCustomizer.Id(k =>
     {
         k.Generator(Generators.Identity);
         k.Column("Id");
         k.UnsavedValue("0");
     });
 }
Esempio n. 8
0
        private void DicriminatorColumnNamedClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            if(DiscriminatorIsNotRequired(type)) return;

            classCustomizer.Discriminator(
                dm =>
                    {
                        dm.Column("Class");
                        dm.NotNullable(true);
                    });
        }
Esempio n. 9
0
        //public static void PluralizeEntityName(Type type, IClassAttributesMapper map)
        //{
        //    map.Table(Service.Pluralize(type.Name));
        //}
        public static void TableNameConvention(Type type, IClassAttributesMapper map)
        {
            var ns     = type.Namespace;
            var prefix = NamespaceMapToTablePrefix[ns.Substring(ns.LastIndexOf(".") + 1)];

            if (prefix == null)
            {
                throw new NetArchException("DomainObject's namespace has not been registered for table mapping:" + ns + "." +
                                           type.Name);
            }
            map.Table(prefix + type.Name);
        }
Esempio n. 10
0
 private static void MapClass(IModelInspector modelinspector, Type type, IClassAttributesMapper @class)
 {
     if (typeof(Entity).IsAssignableFrom(type))
     {
         @class.Id(type.GetProperty("Id"), id =>
         {
             id.Column(type.Name + "Id");
             id.Generator(Generators.GuidComb);
             id.UnsavedValue(Guid.Empty);
         });
         @class.Version(type.GetProperty("Version"), version => {});
     }
 }
Esempio n. 11
0
 private void PrimaryKeyConvention(IModelInspector modelInspector, Type type, IClassAttributesMapper map)
 {
     map.Id(k =>
     {
         foreach (var idProperty in type.GetProperties().Where(modelInspector.IsPersistentId))
         {
             if (IdColumnNaming != null)
             {
                 k.Column(IdColumnNaming(type, idProperty));
             }
         }
     });
 }
Esempio n. 12
0
        private void MapTable(Type type, IClassAttributesMapper map)
        {
            string table = type.Name;

            if (type.Name.EndsWith("y"))
            {
                table = type.Name.TrimEnd('y') + "ies";
            }
            else if (!type.Name.EndsWith("s"))
            {
                table = type.Name + "s";
            }
            map.Table(table);
        }
Esempio n. 13
0
        public static IClassAttributesMapper MapToTable <TOptions>(this IClassAttributesMapper classCustomizer, TableDefinition tableDefinition, TOptions options)
            where TOptions : StoreOptionsBase
        {
            classCustomizer.Table(tableDefinition.Name);
            if (string.IsNullOrEmpty(tableDefinition.Schema))
            {
                classCustomizer.Schema(options.DefaultSchema);
            }
            else
            {
                classCustomizer.Schema(tableDefinition.Schema);
            }

            return(classCustomizer);
        }
Esempio n. 14
0
        public void Apply(Type subject, IClassAttributesMapper applyTo)
        {
            var className = subject.Name;

            if (Array.IndexOf(enumsNames, className) >= 0)
            {
                applyTo.DiscriminatorValue(EnumUtil.ParseGettingUnderlyingValue(typeof(TEnum), className));
            }
            else if (indexOfUnknow >= 0)
            {
                applyTo.DiscriminatorValue(EnumUtil.ParseGettingUnderlyingValue(typeof(TEnum), enumsNames[indexOfUnknow]));
            }
            else
            {
                throw new ArgumentException("Canot find the discriminator value for the class " + subject.FullName + " using the enum " + typeof(TEnum).FullName);
            }
        }
Esempio n. 15
0
        void ApplyClassConvention(IModelInspector mi, Type type, IClassAttributesMapper map)
        {
            if (!_sagaEntities.Contains(type))
            {
                map.Id(idMapper => idMapper.Generator(Generators.GuidComb));
            }
            else
            {
                map.Id(idMapper => idMapper.Generator(Generators.Assigned));
            }

            var tableAttribute = GetAttribute <TableNameAttribute>(type);

            var rowVersionProperty = type.GetProperties()
                                     .Where(HasAttribute <RowVersionAttribute>)
                                     .FirstOrDefault();

            if (rowVersionProperty != null)
            {
                map.Version(rowVersionProperty, mapper => mapper.Generated(VersionGeneration.Always));
            }

            if (tableAttribute != null)
            {
                map.Table(tableAttribute.TableName);
                if (!String.IsNullOrEmpty(tableAttribute.Schema))
                {
                    map.Schema(tableAttribute.Schema);
                }

                return;
            }

            //if the type is nested use the name of the parent
            if (type.DeclaringType != null)
            {
                if (typeof(IContainSagaData).IsAssignableFrom(type))
                {
                    map.Table(type.DeclaringType.Name);
                }
                else
                {
                    map.Table(type.DeclaringType.Name + "_" + type.Name);
                }
            }
        }
        private static void ClassConvention(IModelInspector modelInspector,
                                            Type type,
                                            IClassAttributesMapper classAttributesMapper)
        {
            var schema = IdentityBuilder.BuildSchema(type.Namespace);

            classAttributesMapper.Schema(schema);

            var tableName = IdentityBuilder.BuildTableName(type.Name);

            classAttributesMapper.Table(tableName);

            classAttributesMapper.Id(im => {
                im.Generator(Generators.Assigned);
                im.Column(string.Concat(type.Name,
                                        ConventionNames.PrimaryKeyPostfix));
            });
        }
        /// <summary>
        /// Gets the schema name from the class mapper
        /// </summary>
        /// <param name="classAttributesMapper">An instance that implements IClassAttributesMapper</param>
        /// <returns>The schema name</returns>
        public static string GetSchema(this IClassAttributesMapper classAttributesMapper)
        {
            string schemaName = null;

            if (classAttributesMapper.GetType().Equals(typeof(ClassMapper)))
            {
                var classMappingField = typeof(ClassMapper).GetField("classMapping", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);
                if (classMappingField != null)
                {
                    HbmClass hbmClass = classMappingField.GetValue(classAttributesMapper) as HbmClass;
                    if (hbmClass != null)
                    {
                        schemaName = hbmClass.schema;
                    }
                }
            }

            return(schemaName);
        }
Esempio n. 18
0
        private void MapKey <T>(MemberInfoMetadata key, IClassAttributesMapper <T> classMapper)
            where T : class
        {
            object unsavedKeyValue = 0;

            if (key.Type == typeof(Guid))
            {
                unsavedKeyValue = Guid.Empty;
            }

            classMapper.Id(
                key.Name,
                m =>
            {
                AccessorHelper.SetAccessor(key, m);
                m.Generator(GetGenerator(key.Type));
                m.UnsavedValue(unsavedKeyValue);
            });
        }
Esempio n. 19
0
        private void MapClass(IModelInspector modelInspector, Type classType, IClassAttributesMapper mapper)
        {
            Type entityType = classType.UnderlyingSystemType;

            string schemaName           = namingEngine.ToSchemaName(entityType) ?? mapper.GetSchema();
            string tableName            = namingEngine.ToTableName(entityType);
            var    idProperty           = modelInspector.GetIdentifierMember(entityType);
            var    versionProperty      = modelInspector.GetVersionMember(entityType);
            string primaryKeyColumnName = namingEngine.ToPrimaryKeyColumnName(entityType, idProperty);

            // Mapping
            mapper.Schema(schemaName);
            mapper.Table(tableName);
            mapper.Id(id => id.Column(primaryKeyColumnName));

            // Version mapping
            if (versionProperty != null)
            {
                string versionColumnName = namingEngine.ToColumnName(versionProperty);
                mapper.Version(versionProperty, m => m.Column(versionColumnName));
            }
        }
Esempio n. 20
0
        private void ApplyClassConvention(IModelInspector mi, Type type, IClassAttributesMapper map)
        {
            if (!_sagaEntites.Contains(type))
            {
                map.Id(idMapper => idMapper.Generator(Generators.GuidComb));
            }
            else
            {
                map.Id(idMapper => idMapper.Generator(Generators.Assigned));
            }

            var tableAttribute = GetAttribute <TableNameAttribute>(type);

            if (tableAttribute != null)
            {
                map.Table(tableAttribute.TableName);
                if (!String.IsNullOrEmpty(tableAttribute.Schema))
                {
                    map.Schema(tableAttribute.Schema);
                }
            }
        }
Esempio n. 21
0
        private void MapIdentifier(Type type, IClassAttributesMapper map)
        {
            if (type.HasProperty("ID"))
            {
                string id = type.Name + "ID";
                var    p  = type.GetProperty("ID");

                if (p.PropertyType == typeof(Guid))
                {
                    map.Id(p, x => {
                        x.Column(id);
                        x.Generator(Generators.Guid);
                    });
                }
                else if (p.PropertyType == typeof(int) || p.PropertyType == typeof(long))
                {
                    map.Id(p, x => {
                        x.Column(id);
                        x.Generator(
                            Generators.HighLow,
                            y => y.Params(new {
                            table  = this.HiloTableName,
                            column = this.HiloColumnName,
                            max_lo = 100,
                            where  = String.Format("{0} = '{1}'", this.HiloEntityColumnName, type.Name.ToLowerInvariant())
                        })
                            );
                    });
                }
                else if (p.PropertyType == typeof(string))
                {
                    map.Id(p, x => {
                        x.Column(id);
                        x.Generator(Generators.Assigned);
                    });
                }
            }
        }
Esempio n. 22
0
 public void MakeNotLazy(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
 }
Esempio n. 23
0
 private void MapTableName(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
 {
     classCustomizer.Table(Conventions.GetTableName(type));
 }
Esempio n. 24
0
 private void EscapeAndMaybePluralizeEntityName(IModelInspector modelInspector, Type type, IClassAttributesMapper map)
 {
     if (Pluralize)
     {
         map.Table("`" + service.Pluralize(type.Name) + "`");
     }
     else
     {
         map.Table("`" + type.Name + "`");
     }
 }
Esempio n. 25
0
 protected virtual void OnAfterMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
 }
Esempio n. 26
0
 public static void PluralizeEntityName(Type type, IClassAttributesMapper map)
 {
     map.Table(_service.Pluralize(type.Name));
 }
Esempio n. 27
0
 public static void PluralizeEntityName(Type type, IClassAttributesMapper map)
 {
     map.Table(_service.Pluralize(type.Name));
 }
        protected virtual void NoSetterPoidToField(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = PoidPropertyOrField(modelInspector, type);

            if (poidPropertyOrField != null && MatchNoSetterProperty(poidPropertyOrField))
            {
                classCustomizer.Id(poidPropertyOrField, idm => idm.Access(Accessor.NoSetter));
            }
        }
Esempio n. 29
0
 private void PluralizeTableName(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
     classCustomizer.Table(type.Pluralize());
 }
Esempio n. 30
0
 private void MapVersion(IModelInspector modelinspector, Type type, IClassAttributesMapper classCustomizer)
 {
     foreach (var member in type.GetMembers().Where(member => Mapper.ModelInspector.IsVersion(member)))
     {
         classCustomizer.Version(member, vm => vm.Type((IVersionType) NHibernateUtil.GuessType(member.GetPropertyOrFieldType())));
     }
 }
Esempio n. 31
0
        private void MapHiloId(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            Mapper.AddHiLoScript(EntityHighLowGenerator.GetInsertFor(type));

            classCustomizer.Id(x => x.Generator(new EntityHighLowGeneratorDef(type)));
        }
        /// <summary>
        /// Sets table name and table's schema following the rule that the table name is the same as the type name.
        /// </summary>
        /// <remarks>
        /// Exceptions to the rule:
        ///     - "ClientScope" class has to be mapped to the "ClientScopes" table.
        /// </remarks>
        private void BeforeMapConfigurationStoreClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            TableDefinition tableDef = null;

            if (type == typeof(ClientScope))
            {
                tableDef = GetTableDefinition(nameof(_options.ClientScopes), _options);
            }
            else
            {
                tableDef = GetTableDefinition(type.Name, _options);
            }

            if (tableDef != null)
            {
                classCustomizer.MapToTable(tableDef, _options);
            }

            // Common mapping rule for IDs
            classCustomizer.Id(map =>
            {
                map.Column("Id");
                map.Generator(Generators.Native);
            });
        }
Esempio n. 33
0
        public static void DefaultClassMapper(IModelInspector modelInspector, Type type, IClassAttributesMapper mapper)
        {
            MapSchema(mapper.Schema, type);

            mapper.Id(id =>
            {
                id.Column(type.Name + _foreignKeyColumnPostfix);
                id.Generator(Generators.Identity);
            });
        }
Esempio n. 34
0
 /// <summary>
 /// Sets the mapper to use:
 ///  1) a native generator for int primary keys
 ///  2) a Generators.GuidComb generator for Guid primary keys
 ///  3) a string length of 128 for string primary keys
 /// </summary>
 private void OnMapperOnBeforeMapClass(IModelInspector inspector, Type type, IClassAttributesMapper customizer)
 {
     foreach (var p in type.GetProperties())
     {
         if (inspector.IsPersistentId(p))
         {
             var idType = p.PropertyType;
             if (idType == typeof(int))
             {
                 customizer.Id(x => x.Generator(Generators.Native));
             }
             else if (idType == typeof(string))
             {
                 var customAttributes = p.GetCustomAttributes(false);
                 StringLengthAttribute stringlengthAttribute = (StringLengthAttribute)customAttributes.FirstOrDefault(x => x.GetType() == typeof(StringLengthAttribute));
                 int length = DefaltStringIdLength;
                 if (stringlengthAttribute != null && stringlengthAttribute.MaximumLength > 0)
                 {
                     length = stringlengthAttribute.MaximumLength;
                 }
                 customizer.Id(x => x.Length(length));
             }
             else if (idType == typeof(Guid))
             {
                 customizer.Id(x => { x.Generator(Generators.GuidComb); });
             }
         }
     }
 }
Esempio n. 35
0
        private void ApplyClassLevelAttributeMappings(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            var context = new MappingContext(modelInspector, Conventions);

            foreach (Attribute attr in type.GetCustomAttributes(false))
            {
                foreach(var mapper in _attributeMapperFactory.GetClassAttributeMappers(attr))
                {
                    mapper.ApplyMapping(attr, type, classCustomizer, context);
                }
            }
        }
 protected virtual void NoPoidGuid(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
     MemberInfo poidPropertyOrField = PoidPropertyOrField(modelInspector, type);
     if (ReferenceEquals(null, poidPropertyOrField))
     {
         classCustomizer.Id(null, idm => idm.Generator(Generators.Guid));
     }
 }
        protected override void OnBeforeMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            classCustomizer.DynamicInsert(DynamicInsert);
            classCustomizer.DynamicUpdate(DynamicUpdate);

            classCustomizer.Table(GetTableName(modelInspector, type));

            classCustomizer.Id(
                m =>
                {
                    m.Column(GetKeyColumnName(modelInspector, type, false));
                    m.Generator(Generators.HighLow);
                });

            if (modelInspector.IsTablePerClassHierarchy(type))
            {
                classCustomizer.Discriminator(m => m.Column(GetDiscriminatorColumnName(modelInspector, type)));
                classCustomizer.DiscriminatorValue(GetDiscriminatorValue(modelInspector, type));
            }

            MemberInfo[] versionProperties = VersionProperties(modelInspector, type).ToArray();
            if (versionProperties.Length == 1)
            {
                classCustomizer.Version(versionProperties[0], m => m.Column(GetVersionColumnName(modelInspector, type)));
            }
        }
Esempio n. 38
0
 public void ApplyMapping(Attribute attribute, System.Reflection.MemberInfo idProperty, Type entityType, IClassAttributesMapper mapper, MappingContext context)
 {
     mapper.Id(idProperty, IdMappings.HighLowId(context.Conventions.GetTableName(entityType)));
 }
Esempio n. 39
0
        protected virtual void NoSetterPoidToField(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(modelInspector.IsPersistentId);

            if (MatchNoSetterProperty(poidPropertyOrField))
            {
                classCustomizer.Id(idm => idm.Access(Accessor.NoSetter));
            }
        }
Esempio n. 40
0
        protected virtual void NoPoidGuid(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(mi => modelInspector.IsPersistentId(mi));

            if (!ReferenceEquals(null, poidPropertyOrField))
            {
                return;
            }
            classCustomizer.Id(null, idm => idm.Generator(Generators.Guid));
        }
Esempio n. 41
0
        private void ApplyIdMappings(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
        {
            var member = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(m => modelInspector.IsPersistentId(m));

            if (member != null)
            {
                var idAttr = member.GetCustomAttributes(typeof(IdAttribute), false).OfType<IdAttribute>().FirstOrDefault();

                // If IdAttribute is not specified for persistent id property, then use the default id mapping strategy
                if (idAttr == null)
                {
                    idAttr = new IdAttribute();
                }

                var context = new MappingContext(modelInspector, Conventions);

                foreach (var mapper in _attributeMapperFactory.GetIdAttributeMappers(idAttr))
                {
                    mapper.ApplyMapping(idAttr, member, type, classCustomizer, context);
                }
            }
        }
 public static void AllIdNamedPOIDAndHilo(IModelInspector modelInspector, Type type, IClassAttributesMapper map)
 {
     map.Id(x => x.Generator(Generators.HighLow));
     map.Id(x => x.Column("POID"));
     map.Id(x => x.Type(null));
 }
		protected virtual void NoPoidGuid(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
		{
			MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(mi => modelInspector.IsPersistentId(mi));
			if (!ReferenceEquals(null, poidPropertyOrField))
			{
				return;
			}
			classCustomizer.Id(null, idm=> idm.Generator(Generators.Guid));
		}
 public static void AllIdIdentity(IModelInspector modelinspector, Type type, IClassAttributesMapper classcustomizer)
 {
     classcustomizer.Id(x => x.Generator(Generators.Identity));
 }
 protected virtual void OnBeforeMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
 }
Esempio n. 46
0
        private void DisciminatorValueAsClassName(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            if (DiscriminatorIsNotRequired(type)) return;

            classCustomizer.DiscriminatorValue(type.Name);
        }
 protected virtual void NoSetterPoidToField(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
 {
     MemberInfo poidPropertyOrField = PoidPropertyOrField(modelInspector, type);
     if (poidPropertyOrField != null && MatchNoSetterProperty(poidPropertyOrField))
     {
         classCustomizer.Id(poidPropertyOrField, idm => idm.Access(Accessor.NoSetter));
     }
 }
        protected override void OnBeforeMapClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            classCustomizer.DynamicInsert(DynamicInsert);
            classCustomizer.DynamicUpdate(DynamicUpdate);

            classCustomizer.Table(GetTableName(modelInspector, type));

            classCustomizer.Id(
                m =>
            {
                m.Column(GetKeyColumnName(modelInspector, type, false));
                m.Generator(Generators.HighLow);
            });

            if (modelInspector.IsTablePerClassHierarchy(type))
            {
                classCustomizer.Discriminator(m => m.Column(GetDiscriminatorColumnName(modelInspector, type)));
                classCustomizer.DiscriminatorValue(GetDiscriminatorValue(modelInspector, type));
            }

            MemberInfo[] versionProperties = VersionProperties(modelInspector, type).ToArray();
            if (versionProperties.Length == 1)
            {
                classCustomizer.Version(versionProperties[0], m => m.Column(GetVersionColumnName(modelInspector, type)));
            }
        }
Esempio n. 49
0
        private void BeforeMapOperationalStoreClass(IModelInspector modelInspector, Type type, IClassAttributesMapper classCustomizer)
        {
            TableDefinition tableDef;

            if (type == typeof(PersistedGrant))
            {
                tableDef = GetTableDefinition(nameof(_options.PersistedGrants), _options);
            }
            else
            {
                tableDef = GetTableDefinition(type.Name, _options);
            }

            if (tableDef != null)
            {
                classCustomizer.MapToTable(tableDef, _options);
            }

            classCustomizer.DynamicUpdate(true);
        }
		protected virtual void NoSetterPoidToField(IModelInspector modelInspector, System.Type type, IClassAttributesMapper classCustomizer)
		{
			MemberInfo poidPropertyOrField = MembersProvider.GetEntityMembersForPoid(type).FirstOrDefault(modelInspector.IsPersistentId);
			if(MatchNoSetterProperty(poidPropertyOrField))
			{
				classCustomizer.Id(idm=> idm.Access(Accessor.NoSetter));
			}
		}
 public static void TableNameEnglishPluralizedConvention(IModelInspector modelInspector, Type type, IClassAttributesMapper map)
 {
     map.Table(EnglishPluralizationService.Pluralize(type.Name));
 }
Esempio n. 52
0
        /// <summary>
        /// Maps a property according the naming conventions configuration
        /// </summary>
        /// <param name="modelInspector">The model inspector</param>
        /// <param name="property">The class type</param>
        /// <param name="mapper">The class mapper</param>
        private void MapClass(IModelInspector modelInspector, Type classType, IClassAttributesMapper mapper)
        {
            Type entityType = classType.UnderlyingSystemType;

            string schemaName = namingEngine.ToSchemaName(entityType) ?? mapper.GetSchema();
            string tableName = namingEngine.ToTableName(entityType);
            var idProperty = modelInspector.GetIdentifierMember(entityType);
            var versionProperty = modelInspector.GetVersionMember(entityType);
            string primaryKeyColumnName = namingEngine.ToPrimaryKeyColumnName(entityType, idProperty);

            // Mapping
            mapper.Schema(schemaName);
            mapper.Table(tableName);
            mapper.Id(id => id.Column(primaryKeyColumnName));

            // Version mapping
            if (versionProperty != null)
            {
                string versionColumnName = namingEngine.ToColumnName(versionProperty);
                mapper.Version(versionProperty, m => m.Column(versionColumnName));
            }
        }
 public static void AllIdHilo(IModelInspector modelinspector, Type type, IClassAttributesMapper classcustomizer)
 {
     classcustomizer.Id(x => x.Generator(Generators.HighLow));
 }