예제 #1
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));
            }
        }
예제 #2
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));
            }
        }