BooleanNumericConverter doesn't support NULL

Posts   
 
    
sybjeb
User
Posts: 81
Joined: 20-Sep-2011
# Posted on: 23-Feb-2012 16:07:13   

In my LLBLGEN project, I decided to apply the BooleanNumericConverter to all the database fields corresponding to the following specifications :

**Database type **: tinyint **Precision **: 1

Note : I precise that I use the **MySQL **driver.

It runs exactly as I want but now, I would like to use a nullable tinyint(1) field which I supposed would be converted to a nullable boolean .Net property but a Null reference exception is thrown which is thrown in the BooleanNumericConverter.ConvertFrom method (call to value.GetType() throws the null reference exception).


public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
    bool flag = true;
    string fullName;
    if ((fullName = value.GetType().FullName) != null)

How do you manage this kind of field?

sybjeb
User
Posts: 81
Joined: 20-Sep-2011
# Posted on: 23-Feb-2012 17:30:53   

I saw on the following thread that I need to re-compile the TypeConverter dll to be able to manage it.

Thread : 'System.DBNull' to System.Boolean isn't supported

1) I think it would be great that LLBLGEN provides a default implementation and I propose nullable -> nullable. Indeed, when an integer field is nullable in database, you convert it automatically to a nullable integer in .Net, why don't you do the same thing for boolean?

2) In the above thread, you wrote "All the necessary information about developing your own TypeConverter is available in the LLBLGen Pro SDK manual: 'Implementing a typeconverter'". Where can I find this manual? I tried to download the "LLBLGen Pro v3.1 Runtime library reference manual" but no page is displayed.

3) I downloaded the LLBLGEN source code and try to recompile the TypeConverter project bu it doesn't. It references** NHibernate** that I haven't because I didn't use it at all. So, I downloaded it. Now, when I compile it doesn't find the following path C:\Myprojects\mystrongkey.key". Normal, I haven't. If I comment it, the error is on the post build event.

=> Please, tell me where I can find the manual.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 24-Feb-2012 06:41:24   

sybjeb wrote:

1) I think it would be great that LLBLGEN provides a default implementation and I propose nullable -> nullable. Indeed, when an integer field is nullable in database, you convert it automatically to a nullable integer in .Net, why don't you do the same thing for boolean?

The BooleanNumericTypeConverter was introduced as an example, so people have an start point to do more converters. Anyway, in LLBLGen v3.5 (now in beta) there are a lot of common type converters built-in, and all they are null-aware, so they return null if the value is null.

sybjeb wrote:

2) In the above thread, you wrote "All the necessary information about developing your own TypeConverter is available in the LLBLGen Pro SDK manual: 'Implementing a typeconverter'". Where can I find this manual? I tried to download the "LLBLGen Pro v3.1 Runtime library reference manual" but no page is displayed.

That is the RTL reference manual which is just a reference for all the classes at the runtime assemblies. To see the SDK manual go here: http://llblgen.com/documentation/3.0/SDK/hh_start.htm

sybjeb wrote:

3) I downloaded the LLBLGEN source code and try to recompile the TypeConverter project bu it doesn't. It references** NHibernate** that I haven't because I didn't use it at all.

There are two projects in the TypeConverter solution, if you don't use NH, just remove that project from the solution and compile the other one.

sybjeb wrote:

So, I downloaded it. Now, when I compile it doesn't find the following path C:\Myprojects\mystrongkey.key". Normal, I haven't. If I comment it, the error is on the post build event.

It's because the assembly signing. Go to AssemblyInfo.cs and remove/comment these lines:

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("C:\\Myprojects\\mystrongkey.key")]
[assembly: AssemblyKeyName("")]
David Elizondo | LLBLGen Support Team
sybjeb
User
Posts: 81
Joined: 20-Sep-2011
# Posted on: 24-Feb-2012 10:03:19   

Your answer is just perfect. => I downloaded the 3.5 version and all is OK now.

I could not expected more !!!