Boolean values

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
fni
Posts: 25
Joined: Wed 27 Jan 2010 13:20

Boolean values

Post by fni » Tue 16 Mar 2010 13:52

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?

JonasJ
Posts: 8
Joined: Wed 25 Nov 2009 08:51

Post by JonasJ » Wed 17 Mar 2010 08:28

I'm pretty sure you can't (unless you creata a queryview, but they have their own limitations).

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 18 Mar 2010 10:35

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.

Alladin
Posts: 149
Joined: Mon 27 Nov 2006 16:18
Contact:

Post by Alladin » Fri 09 Apr 2010 22:04

Will this mapper work for selects?

Alladin
Posts: 149
Joined: Mon 27 Nov 2006 16:18
Contact:

Post by Alladin » Fri 09 Apr 2010 22:07

I mean for selects like this:
from t in ctx.Customers where t.BoolWrapper select t;

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 12 Apr 2010 14:56

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.

Alladin
Posts: 149
Joined: Mon 27 Nov 2006 16:18
Contact:

Post by Alladin » Tue 13 Apr 2010 01:44

Thank you. Number(1) is almost fine (except that it needs 8 times more bytes in record buffer)

Post Reply