This question is locked. New answers and comments are not allowed.
Hello,
I would like to know if it is possible to map Varchar(1) to boolean. I am using Oracle as Database, and boolean is stored as Varchar(1) = 'S' to True and 'N' to False.
I would like to know if it is possible to map Varchar(1) to boolean. I am using Oracle as Database, and boolean is stored as Varchar(1) = 'S' to True and 'N' to False.
6 Answers, 1 is accepted
0
Hi Alex,
We are currently working on a mechanism where this would be possible and you can 'plug in' your own implementation that decides what is a 'true' value and what is 'false'.
At the moment what you could do is map the column to a 'char' member field in your class and implement the IInstanceCallbacks interface to check this value and assign the appropriate value to another 'bool' transient field. This way the 'char' fields get persisted to the database and you get/set the value via the 'bool' which is transient (not saved to the database).
Do get back in case you have further questions.
Greetings,
Ady
the Telerik team
We are currently working on a mechanism where this would be possible and you can 'plug in' your own implementation that decides what is a 'true' value and what is 'false'.
At the moment what you could do is map the column to a 'char' member field in your class and implement the IInstanceCallbacks interface to check this value and assign the appropriate value to another 'bool' transient field. This way the 'char' fields get persisted to the database and you get/set the value via the 'bool' which is transient (not saved to the database).
Do get back in case you have further questions.
Greetings,
Ady
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
answered on 23 Sep 2010, 06:50 PM
Hello Ady,
Thank you by the solution, I dealed with this in a different way, changing the string property privacy to "Private" and creating another public property in the partial class that maps 'S' and 'N' to Boolean. I really would like to know about a native way to implement, I hope it can be released soon.
Thanks.
Thank you by the solution, I dealed with this in a different way, changing the string property privacy to "Private" and creating another public property in the partial class that maps 'S' and 'N' to Boolean. I really would like to know about a native way to implement, I hope it can be released soon.
Thanks.
0
Alex
Top achievements
Rank 1
answered on 24 Sep 2010, 07:39 PM
Hello,
Addy I was testing your solution and implementing IInstanceCallbacks.
But how can I configure the generated class to implement the Interface IInstanceCallbacks ?
Sds,
Addy I was testing your solution and implementing IInstanceCallbacks.
But how can I configure the generated class to implement the Interface IInstanceCallbacks ?
Sds,
0
Hello Alex,
Currently there is no tool/wizard to automatically implement this interface for you. All you need to do is implement methods of this interface in your class (as shown in the help) and the OpenAccess runtime will invoke the appropriate methods when the events occur.
Do get back in case you need answers to specific questions on how to implement the interface.
Best wishes,
Ady
the Telerik team
Currently there is no tool/wizard to automatically implement this interface for you. All you need to do is implement methods of this interface in your class (as shown in the help) and the OpenAccess runtime will invoke the appropriate methods when the events occur.
Do get back in case you need answers to specific questions on how to implement the interface.
Best wishes,
Ady
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
DuelingCats
Top achievements
Rank 2
answered on 19 Feb 2013, 05:39 PM
Is it still the case that there isn't an automatic way to make a varchar 1 to bool?
0
Hello Alex,
I have prepared a sample for you where you can convert between a varchar(1) to a Bool. Following is some information related to that
Regards,
Ady
the Telerik team
I have prepared a sample for you where you can convert between a varchar(1) to a Bool. Following is some information related to that
- When you reverse map your schema to a model you need to explicitly specify the CLR type as 'bool'. By default a varchar(1) will be mapped to a 'char'
- Converting between a character to a boolean is done via the 'Type converter' framework. I have implemented a custom type converter - VarcharToBooleanConverter which does this. You can modify it based on your interpretation of 'true' and 'false'
- You will also need to create a partial class for your context and override the 'OnDatabaseOpen' method. Here you need to set the converter for the fields that need to be converted.
Please have a look at the example and get back in case you need further assistance.
Regards,
Ady
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.