mono-list  

Re: [Mono-list] How to fix System.Data.Linq.Mapping.ColumnAttribute.CanBeNull default value False

Robert Jordan
Fri, 05 Mar 2010 03:05:41 -0800

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

_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list