ColumnAttribute ColumnAttribute ColumnAttribute ColumnAttribute Class

定义

将类与数据库表中的列相关联。 Associates a class with a column in a database table.

public ref class ColumnAttribute sealed : System::Data::Linq::Mapping::DataAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple=false)]
public sealed class ColumnAttribute : System.Data.Linq.Mapping.DataAttribute
type ColumnAttribute = class
    inherit DataAttribute
Public NotInheritable Class ColumnAttribute
Inherits DataAttribute
继承
属性

示例

<Table(Name:="Employees")>  _  
Public Class Employees  
    Private _LastName As String  
    ' …  
    <Column(Storage:="_LastName", DbType:="NVarChar(20) NOT NULL", _  
        CanBeNull:=false)> _  
    Public Property LastName() As String  
        Get  
            Return Me._LastName  
        End Get  
        Set  
            If ((Me._LastName = value) _  
                = false) Then  
                Me.OnPropertyChanging("LastName")  
                Me._LastName = value  
                Me.OnPropertyChanged("LastName")  
            End If  
        End Set  
    End Property  
End Class  
[Table(Name="Employees")]  
public class Employees  
{  
    private string _LastName;      
    // …  
    [Column(Storage="_LastName", DbType="NVarChar(20) NOT NULL",   
        CanBeNull=false)]  
    public string LastName  
    {  
        get  
        {  
            return this._LastName;  
        }  
        set  
        {  
            if ((this._LastName != value))  
            {  
                this.OnPropertyChanging("LastName");  
                this._LastName = value;  
                this.OnPropertyChanged("LastName");  
            }  
        }  
    }  
}  

注解

使用此属性可指定实体类的某个成员表示数据库表中的列。Use this attribute to designate a member of an entity class to represent a column in a database table. 可以将此特性应用于任何字段或属性是publicprivate,或internalYou can apply this attribute to any field or property that is public, private, or internal.

只有标识为列持久化的实体类成员时LINQ to SQLLINQ to SQL将更改保存到数据库。Only those entity class members identified as columns are persisted when LINQ to SQLLINQ to SQL saves changes to the database.

使用逗号分隔多个特性的属性。Use commas to separate multiple properties on the attribute.

构造函数

ColumnAttribute() ColumnAttribute() ColumnAttribute() ColumnAttribute()

初始化 ColumnAttribute 类的新实例。 Initializes a new instance of the ColumnAttribute class.

属性

AutoSync AutoSync AutoSync AutoSync

获取或设置 AutoSync 枚举。 Gets or sets the AutoSync enumeration.

CanBeNull CanBeNull CanBeNull CanBeNull

获取或设置一个值,该值指示列是否可包含 null 值。 Gets or sets whether a column can contain null values.

DbType DbType DbType DbType

获取或设置数据库列的类型。 Gets or sets the type of the database column.

Expression Expression Expression Expression

获取或设置一个值,该值指示列是否为数据库中的计算列。 Gets or sets whether a column is a computed column in a database.

IsDbGenerated IsDbGenerated IsDbGenerated IsDbGenerated

获取或设置一个值,该值指示列是否包含数据库自动生成的值。 Gets or sets whether a column contains values that the database auto-generates.

IsDiscriminator IsDiscriminator IsDiscriminator IsDiscriminator

获取或设置一个值,该值指示列是否包含 LINQ to SQLLINQ to SQL 继承层次结构的鉴别器值。 Gets or sets whether a column contains a discriminator value for a LINQ to SQLLINQ to SQL inheritance hierarchy.

IsPrimaryKey IsPrimaryKey IsPrimaryKey IsPrimaryKey

获取或设置一个值,该值指示该类成员是否表示作为表的整个主键或部分主键的列。 Gets or sets whether this class member represents a column that is part or all of the primary key of the table.

IsVersion IsVersion IsVersion IsVersion

获取或设置一个值,该值指示成员的列类型是否为数据库时间戳或版本号。 Gets or sets whether the column type of the member is a database timestamp or version number.

Name Name Name Name

获取或设置列名称。 Gets or sets the name of a column.

(Inherited from DataAttribute)
Storage Storage Storage Storage

获取或设置私有存储字段以保存列中的值。 Gets or sets a private storage field to hold the value from a column.

(Inherited from DataAttribute)
TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。 When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
UpdateCheck UpdateCheck UpdateCheck UpdateCheck

获取或设置一个值,该值指示 LINQ to SQLLINQ to SQL 如何进行开放式并发冲突的检测。 Gets or sets how LINQ to SQLLINQ to SQL approaches the detection of optimistic concurrency conflicts.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。 Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。 Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 Type Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。 When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。 When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。 Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。 Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。 Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。 Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。 Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

适用于