Modeling a boolean value in an Oracle database

2 posts, 0 answers
  1. Chen
    Chen avatar
    18 posts
    Member since:
    Apr 2012

    Posted 07 Jun 2012 Link to this post

    I have a boolean value want to save to Oracle database. Since Oracle does not support "bit" type, I have to use Number(0,1) and I can't map it to a boolean property in my mapping class. I used int type to map to database and convert it to boolean when I use it in my code.

    Is there a way I can map the boolean property to the Oracle database table directly?

    Thanks in advance.
  2. Ralph Waldenmaier
    Ralph Waldenmaier avatar
    202 posts

    Posted 08 Jun 2012 Link to this post

    Hello Chen,

    You can specify you property as boolean directly. There is no need for you to do some extra casts in your project. 
    Please see the attached sample project, where I have an example for a forward mapped boolean, which is translated to the db type number. Also you can find a reverse project, where I used a number(1) db type that is mapped to a boolean in my domain class. Please adjust the connection string in the app.config to work with the projects.

    I hope this information is useful for you.
    Feel free to ask if you have any other question.

    Kind regards,
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
Back to Top