

[Column(Storage= "_number" , DbType= "VarChar(50) NOT NULL" , CanBeNull= false )]
public string number
{ get { .... } set { .... } }
* This source code was highlighted with Source Code Highlighter .partial class LinqBugTable
{
public void WriteNullableInfo()
{
foreach (PropertyInfo property in GetType().GetProperties())
{
foreach (ColumnAttribute columnAttribute in property.GetCustomAttributes( typeof (ColumnAttribute), true ))
{
Console .WriteLine( "Property: '{0}', CanBeNull: '{1}'" , property.Name, columnAttribute.CanBeNull);
}
}
}
}
* This source code was highlighted with Source Code Highlighter .[Column(Storage= "_price" , DbType= "Money NOT NULL" )]
public decimal price
{ get { .... } set { .... } }
* This source code was highlighted with Source Code Highlighter .
public void WriteNullableInfo()
{
foreach (PropertyInfo property in GetType().GetProperties())
{
foreach (ColumnAttribute columnAttribute in property.GetCustomAttributes( typeof (ColumnAttribute), true ))
{
bool canBeNull = (Nullable.GetUnderlyingType(property.PropertyType) != null )
|| (columnAttribute.CanBeNull && !property.PropertyType.IsValueType);
Console .WriteLine( "Property: '{0}', CanBeNull: '{1}'" , property.Name, canBeNull);
}
}
}
* This source code was highlighted with Source Code Highlighter .Source: https://habr.com/ru/post/58119/
All Articles