ColumnAttribute 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将类与数据库表中的列相关联。
public ref class ColumnAttribute sealed : System::Data::Linq::Mapping::DataAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class ColumnAttribute : System.Data.Linq.Mapping.DataAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
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");
}
}
}
}
注解
使用此属性可指定实体类的成员来表示数据库表中的列。 可以将此属性应用于任何字段或属性 public, private或 internal。
当 LINQ to SQL 保存对数据库的更改时,仅保留标识为列的实体类成员。
使用逗号分隔属性上的多个属性。
构造函数
| 名称 | 说明 |
|---|---|
| ColumnAttribute() |
初始化 ColumnAttribute 类的新实例。 |
属性
| 名称 | 说明 |
|---|---|
| AutoSync |
获取或设置 AutoSync 枚举。 |
| CanBeNull |
获取或设置列是否可以包含 null 值。 |
| DbType |
获取或设置数据库列的类型。 |
| Expression |
获取或设置列是否是数据库中的计算列。 |
| IsDbGenerated |
获取或设置列是否包含数据库自动生成的值。 |
| IsDiscriminator |
获取或设置列是否包含 LINQ to SQL 继承层次结构的歧视性值。 |
| IsPrimaryKey |
获取或设置此类成员是否表示作为表的一部分或所有主键的列。 |
| IsVersion |
获取或设置成员的列类型是数据库时间戳还是版本号。 |
| Name |
获取或设置列的名称。 (继承自 DataAttribute) |
| Storage |
获取或设置一个专用存储字段,用于保存列中的值。 (继承自 DataAttribute) |
| TypeId |
在派生类中实现时,获取此 Attribute的唯一标识符。 (继承自 Attribute) |
| UpdateCheck |
获取或设置 LINQ to SQL 如何接近对乐观并发冲突的检测。 |
方法
| 名称 | 说明 |
|---|---|
| Equals(Object) |
返回一个值,该值指示此实例是否等于指定对象。 (继承自 Attribute) |
| GetHashCode() |
返回此实例的哈希代码。 (继承自 Attribute) |
| GetType() |
获取当前实例的 Type。 (继承自 Object) |
| IsDefaultAttribute() |
在派生类中重写时,指示此实例的值是否为派生类的默认值。 (继承自 Attribute) |
| Match(Object) |
在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。 (继承自 Attribute) |
| MemberwiseClone() |
创建当前 Object的浅表副本。 (继承自 Object) |
| ToString() |
返回一个表示当前对象的字符串。 (继承自 Object) |
显式接口实现
| 名称 | 说明 |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
将一组名称映射为对应的一组调度标识符。 (继承自 Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
检索对象的类型信息,该信息可用于获取接口的类型信息。 (继承自 Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
检索对象提供的类型信息接口的数量(0 或 1)。 (继承自 Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
提供对对象公开的属性和方法的访问。 (继承自 Attribute) |