ColumnAttribute.CanBeNull Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece si una columna puede contener valores NULL.
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 propiedad
Predeterminado = true.
Ejemplos
[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
Comentarios
Si establece este valor falseen , se supone que los datos de la columna correspondiente no son NULL.
Nota:
Esta propiedad se duplica desde la DbType propiedad para mayor comodidad. El CreateDatabase método usa solo la DbType propiedad . Por este motivo, debe especificar si una columna puede contener valores NULL en la DbType propiedad también.