Print Page | Close Window

Datatype Conversion

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3260
Printed Date: 02-May-2024 at 9:24am


Topic: Datatype Conversion
Posted By: SandLink
Subject: Datatype Conversion
Date Posted: 11-Feb-2012 at 10:06am
I have a legacy DB running on Oracle which has a few specific internal data representations which need to be converted into more standard data types in my entities. To whit:
Booleans are represented as 0 or 1, which is a NUMBER1. The designer maps the values as Int16, and throws an exception when I want to use an Boolean.
Empty strings in Oracle are represented as single space strings, while an empty string '' is NULL.
What I need is to be able to convert from the DB representation to a CLR representation in the mapping layer, but I can't find any information as to any available handles for this.
Apart from costly workarounds like duplicating all my properties, are there any elegant solutions to the problem?



Replies:
Posted By: sbelini
Date Posted: 13-Feb-2012 at 8:59am
Hi SandLink,
 
Regarding your NUMBER(1,0) type the only way I could see the 'conversion' is to actually have a custom property (boolean) that would assign/retrieve (i.e. via property interceptor) the proper int value (after all the field is of int type even though it only takes 0s and 1s).
 
As for empty strings, you can set ShouldTreatEmptyStringAsNull to false:
 
myEM.VerifierEngine.DefaultVerifierOptions.ShouldTreatEmptyStringAsNull = false;
 
Regards,
   Silvio.



Print Page | Close Window