LinqConnect Documentation
In This Topic
    Entity Class Mapping
    In This Topic

    Entity class mapping allows you to customize the name of the table in the database this class is mapped to. It is not required to specify the table name - if this information is not specified, it is assumed that the table has the same name as the entity class. For information on mapping class members and keys see the Member Mapping and Primary Key Mapping topics.

    Parameter Type Description Default Value
    Name String The name of the database table the entity is mapped to. May contain the schema identifier explicitly. By default, LinqConnect considers the table name equal to the entity class name.

    Attribute Mapping

    Table attribute is used for mapping entity classes using attribute mapping.


    [Table(Name = "MY_SCHEMA.MY_TABLE")]
    public class MyClass {
        // ...
    }
     
    [Table(Name = "CRM_DEMO.\"Company\"")]
    internal class Company {
        // ...
    }
     
    [Table]
    internal class Order {
        // ...
    }
    
    <Table(Name:="MY_SCHEMA.MY_TABLE")> _
    Public Class [MyClass]
        '...
    End Class
    
    <Table(Name:="CRM_DEMO.""Company""")> _
    Class Company
        '...
    End Class
    
    <Table()> _
    Class Order
        '...
    End Class
    
    

    XML Mapping

    XML mapping of entity classes uses Table tags with the Type element. The Name attribute of the Table tag specifies the corresponding database table name, and the Name attribute of the Type tag specifies the name of the class.

    <Table Name="MY_SCHEMA.MY_TABLE">
      <Type Name="MyClass">
    ...
      </Type>
    </Table>
    <Table Name="CRM_DEMO.&quot;Company&quot;">
      <Type Name="Company">
    ...
      </Type>
    </Table>
    <Table Name="Order">
      <Type Name="Order">
    ...
      </Type>
    </Table>

    Fluent Mapping

    FluentMappingBuilder class methods are used for mapping DataContext.


    FluentMappingBuilder builder = new FluentMappingBuilder(null);
     
    builder.Entity<MyClass>()
        .FullTableName("MY_SCHEMA.MY_TABLE");
     
    builder.Entity<Company>()
        .SchemaName("CRM_DEMO")
        .TableName("Company");
     
    builder.Entity(typeof(Order));
    
    Dim builder As New FluentMappingBuilder(Nothing)
    
    builder.Entity(Of [MyClass]) _
        .FullTableName("MY_SCHEMA.MY_TABLE")
    
    builder.Entity(Of Company) _
        .SchemaName("CRM_DEMO") _
        .TableName("Company")
    
    builder.Entity(GetType(Order))
    
    

    For more information see the Specifying Table Name topic.