Page 1 of 1

Boolean values

Posted: Tue 16 Mar 2010 13:52
by fni
How can I map a CHAR(1) column containing 'Y' or 'N' to a boolean on the Entity Framework using Devart Oracle dotConnect and Entity Framework?

Posted: Wed 17 Mar 2010 08:28
by JonasJ
I'm pretty sure you can't (unless you creata a queryview, but they have their own limitations).

Posted: Thu 18 Mar 2010 10:35
by AndreyR
You can try adding similar code to the partial entity definition in the DataSourceModel.cs file in case you are using Devart Entity model:

Code: Select all

    public bool? BoolWrapper {
      get {
        if (Boolfield == null)
          return null;
        if (Boolfield == "Y" || Boolfield == "y")
          return true;
        if (Boolfield == "N" || Boolfield == "n")
          return false;
        return null;
      }
      set {
        if (value != null)
          if (value == true)
            Boolfield = "Y";
          else
            Boolfield = "N";
        else
          Boolfield = null;
      }
    }
This wrapper works for inserts and updates.

Posted: Fri 09 Apr 2010 22:04
by Alladin
Will this mapper work for selects?

Posted: Fri 09 Apr 2010 22:07
by Alladin
I mean for selects like this:
from t in ctx.Customers where t.BoolWrapper select t;

Posted: Mon 12 Apr 2010 14:56
by AndreyR
No. Such selects need a property having ColumnAttribute.
The Number(1) column can be easily mapped to bool in design time of Entity Developer, everything works OK.
Unfortunately, the only solution for Char(1) field is the wrapper I have mentioned.

Posted: Tue 13 Apr 2010 01:44
by Alladin
Thank you. Number(1) is almost fine (except that it needs 8 times more bytes in record buffer)