ColumnAttribute.CanBeNull Propriedade

Definição

Obtém ou define se uma coluna pode conter valores nulos.

public:
 property bool CanBeNull { bool get(); void set(bool value); };
public bool CanBeNull { get; set; }
member this.CanBeNull : bool with get, set
Public Property CanBeNull As Boolean

Valor de Propriedade

Padrão = true.

Exemplos

[Column(Storage="_LastName", DbType="NVarChar(20) NOT NULL", CanBeNull=false)]
public string LastName
{
    get
    {
        return this._LastName;
    }
    set
    {
        if ((this._LastName != value))
        {
            this.OnLastNameChanging(value);
            this.SendPropertyChanging();
            this._LastName = value;
            this.SendPropertyChanged("LastName");
            this.OnLastNameChanged();
        }
    }
}
<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.OnLastNameChanging(value)
            Me.SendPropertyChanging
            Me._LastName = value
            Me.SendPropertyChanged("LastName")
            Me.OnLastNameChanged
        End If
    End Set
End Property

Observações

Se definir este valor para false, os dados na coluna correspondente assumem-se que não são nulos.

Note

Esta propriedade é duplicada a partir da DbType propriedade para maior conveniência. O CreateDatabase método utiliza apenas a propriedade DbType . Por esta razão, deve especificar se uma coluna pode conter valores nulos na DbType propriedade também.

Aplica-se a