Partilhar via


ColumnAttribute.Required Property

Gets or sets a value that indicates whether the field (column) is required to have a value.

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

Syntax

'Declaration
Public Property Required As Boolean
    Get
    Set
'Usage
Dim instance As ColumnAttribute
Dim value As Boolean

value = instance.Required

instance.Required = value
public bool Required { get; set; }

Property Value

Type: System.Boolean
true, if the field must have a value; false otherwise.

Examples

The following example shows Required in use:

[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.
}

See Also

Reference

ColumnAttribute Class

ColumnAttribute Members

Microsoft.SharePoint.Linq Namespace