更新:2007 年 11 月
命名空间:
System.Data.Linq.Mapping 程序集:
System.Data.Linq(在 System.Data.Linq.dll 中)
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False)> _
Public NotInheritable Class ColumnAttribute _
Inherits DataAttribute
Dim instance As ColumnAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public sealed class ColumnAttribute : DataAttribute
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field, AllowMultiple = false)]
public ref class ColumnAttribute sealed : public DataAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false) */
public final class ColumnAttribute extends DataAttribute
public final class ColumnAttribute extends DataAttribute
使用此属性可指定实体类的某个成员表示数据库表中的列。可以将此属性应用于 public、private 或 internal 类型的任何字段或属性。
当 LINQ to SQL 保存对数据库所做的更改时,只有那些标识为列的实体类成员是持久的。
使用逗号分隔属性 (Attribute) 的多个属性 (Property)。
<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");
}
}
}
}
System..::.Object
System..::.Attribute
System.Data.Linq.Mapping..::.DataAttribute
System.Data.Linq.Mapping..::.ColumnAttribute
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5
参考