Class TableAttribute
Maps databse table or view to a class or interface. You can apply it to any class including non-public, nester or abstract classes. Applying it to interfaces will allow you to perform queries against target table, but you need to specify projection in your query explicitly, if you want to select data from such mapping.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true, Inherited = true)]
public class TableAttribute : MappingAttribute, _Attribute
- Inheritance
-
TableAttribute
- Implements
- Inherited Members
- Extension Methods
Constructors
TableAttribute()
Creates new table mapping attribute.
public TableAttribute()
TableAttribute(string)
Creates new table mapping attribute.
public TableAttribute(string tableName)
Parameters
tableName
stringName of mapped table or view in database.
Properties
Database
Gets or sets optional database name, to override default database name. See DatabaseName<T>(ITable<T>, string?) method for support information per provider.
public string? Database { get; set; }
Property Value
IsColumnAttributeRequired
Gets or sets column mapping rules for current class or interface.
If true
, properties and fields should be marked with one of those attributes to be used for mapping:
- ColumnAttribute;
- PrimaryKeyAttribute;
- IdentityAttribute;
- ColumnAliasAttribute. Otherwise all supported members of scalar type will be used:
- public instance fields and properties;
- explicit interface implementation properties.
Also see IsStructIsScalarType and ScalarTypeAttribute.
Default value:
true
.
public bool IsColumnAttributeRequired { get; set; }
Property Value
IsTemporary
Gets or sets IsTemporary flag. See IsTemporary<T>(ITable<T>, bool) method for support information per provider.
public bool IsTemporary { get; set; }
Property Value
IsView
This property is not used by linq2db and could be used for informational purposes.
public bool IsView { get; set; }
Property Value
Name
Gets or sets name of table or view in database. When not specified, name of class or interface will be used.
public string? Name { get; set; }
Property Value
Schema
Gets or sets optional schema/owner name, to override default name. See SchemaName<T>(ITable<T>, string?) method for support information per provider.
public string? Schema { get; set; }
Property Value
Server
Gets or sets optional linked server name. See ServerName<T>(ITable<T>, string?) method for support information per provider.
public string? Server { get; set; }
Property Value
TableOptions
Gets or sets Table options. See TableOptions enum for support information per provider.
public TableOptions TableOptions { get; set; }
Property Value
Methods
GetObjectID()
Returns mapping attribute id, based on all attribute options.
public override string GetObjectID()