[Mono-list] How to fix System.Data.Linq.Mapping.ColumnAttribute.CanBeNull default value False
Robert Jordan
robertj at gmx.net
Fri Mar 5 06:05:19 EST 2010
On 05.03.2010 09:19, Andrus wrote:
> In MONO 2.4 and 2.6.1 code below outputs
>
> canbenull==False
>
> How to fix ?
>
> Andrus.
>
>
> using System;
> using System.Data.Linq.Mapping;
> using System.Reflection;
>
> public class Kontekst
> {
> [Column()]
> public DateTime? Akuupaev { get; set; }
> }
>
> class Program
> {
> static void Main()
> {
> const BindingFlags FLAGS = BindingFlags.Instance |
> BindingFlags.Public | BindingFlags.NonPublic;
> const MemberTypes PROP_FIELD = MemberTypes.Property |
> MemberTypes.Field;
> Type type = typeof(Kontekst);
> foreach (MemberInfo member in type.GetMembers(FLAGS))
> {
> if ((member.MemberType& PROP_FIELD) == 0) continue;
> ColumnAttribute col = Attribute.GetCustomAttribute(member,
> typeof(ColumnAttribute)) as ColumnAttribute;
> if (col == null) continue;
> Console.WriteLine("canbenull=={0}", col.CanBeNull);
> }
> Console.ReadLine();
> }}
CanBeNull defaults to "true" in MS.NET and to "false" in Mono, unless
it has been applied at annotation time:
[Column(CanBeNull = true)]
That's how you can fix it :), but please file a bug.
Robert
More information about the Mono-list
mailing list