Page 1 of 1

Integer(0) mapped to Boolean is incorrect

Posted: Wed 10 Nov 2010 18:11
by gabondmk
In summary - how can I change the default data type mapping for an Entity Data Model generated when using dotConnect for Oracle? Number(0) which can hold values from 0 to 9 is being mapped to a Boolean. I need this to be something like Byte so that the value is not lost.

The details:

I am using Devart dotConnect for Oracle to create an ADO.NET Entity Data Model (which is then exposed as a WCF Data Service).

The Oracle data type Integer(0) is being mapped to bool (SSDL), Boolean (CSDL) and System.Boolean (.NET). This is as defined in the 'Entity Framework Data Type Mapping'.

However this data type can store a single digit number (from 0 to 9) in Oracle. Mapping this to a Boolean provides True or False.

The Oracle database that I am connecting to uses values in the full range of 0 to 9 so mapping this to a Boolean loses this information.

I cannot change the Oracle database schema and I need the Entity Data Model to create entities that can manage values from 0 to 9.

How can I change the default mapping to map Number(0) in Oracle to say Byte in .NET? I understand that Byte could hold values larger than 9 but I just need an automatic type that covers all possible values inthe database.

This needs to be automatic in the model generation as there are hundreds of tables with Number(0) fields.

Hoping for a quick response - it will be very much appreciated.

Posted: Thu 11 Nov 2010 14:32
by AndreyR
The solution is to simply find all "bool" occurences in SSDL, replace them with "byte" and perform the same actions with "Boolean" and "Byte" in CSDL using Visual Studio XML Editor (or any other XML editor).
We are working on the possibility of changing the default mapping in Entity Developer, but we don't have any definite timeframe as for implementing this functionality.

Posted: Thu 11 Nov 2010 18:59
by gabondmk
Thanks for the reply. I have just had some success with using the Entity Developer tool to do the model editing. In fact I used Decimal with precision 1 in both places and this worked. So I can now correctly read the underlying values.

The problem with having default mappings with no way to override this default behaviour is that it can never be right for all situations.

If the size of any field in the database is differnet to the size in the mapped .NET object (which cannot be avoided), then it is prone to error. If it is larger in .NET then it will always read successfuly, but could fail on a write (since it could be too large). If it is larger in the database then the read could fail but a write would always succeed.

Since there is no perfect answer there needs to be a way to specify or override default behaviour, otherwise there will always be someone who will have an issue with any default mapping.

In the meantime I will have to write code to process the generated models to correct such issues and recompile. This is painfull but at least I have a way forward.

Perhaps when generating from a database the default mapped .NET data type should be either the same size or larger. That way the read will work and application logic could cater for validation to make sure nothing too large is written back.

So the Number(1) (i.e. one digit number) would not map to a Boolean (by default).

Posted: Fri 12 Nov 2010 12:39
by AndreyR
As I have already mentioned, we plan to implement this functionality.
You can influence our Roadmap using Devart User Voice.

Posted: Fri 09 Dec 2011 16:59
by StanislavK
The possibility of changing the default data type mapping used by Entity Developer is implemented in the latest 6.60.258 build of dotConnect for Oracle. The new build can be downloaded from
http://www.devart.com/dotconnect/oracle/download.html
(the trial version) or from Registered Users' Area (for users with active subscription only).

For the detailed information about the fixes and improvements available in dotConnect for Oracle 6.60.258, please refer to
http://www.devart.com/forums/viewtopic.php?t=22836