共用方式為


ColumnAttribute Class

Specifies that the property is mapped to a field (column) in a Microsoft SharePoint Foundation list.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.SharePoint.Linq.DataAttribute
      Microsoft.SharePoint.Linq.ColumnAttribute

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple := False)> _
Public NotInheritable Class ColumnAttribute _
    Inherits DataAttribute
'Usage
Dim instance As ColumnAttribute
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false)]
public sealed class ColumnAttribute : DataAttribute

Remarks

Every property that is mapped to a field must have this attribute..

Examples

The following is an example of a content type class with a property that is decorated with the ColumnAttribute:

[ContentType(Name="Item", Id="0x01", List="Team Members")]
[DataContract()]
public partial class TeamMembersItem : Item {
    
    private System.Nullable<double> _memberID;
        
    public TeamMembersItem() {
        this.Initialize();
    }

    [Column(Name="MemberID", Storage="_memberID", Required=true, FieldType="Number")]
    [DataMember()]
    public System.Nullable<double> MemberID {
        get {
            return this._memberID;
        }
        set {
            if ((this._memberID != value)) {
                this.OnPropertyChanging("MemberID", this._memberID);
                this._memberID = value;
                this.OnPropertyChanged("MemberID");
            }
        }
    }

    // Other members omitted for readability.
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ColumnAttribute Members

Microsoft.SharePoint.Linq Namespace