示例#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));
            }
        }