NULL exception when writing bools in inheritance scenario

Posts   
 
    
Sokon1
User
Posts: 97
Joined: 17-Jul-2006
# Posted on: 06-Sep-2006 15:06:04   

Hi!

I've got two Entities. One inherits from the other. The parent entity has got a non nullable bool field.

When I try this, I get an NULL-Exception.


ParentEntity newEnt = new ChildEntity();
newEnt.Save();

If I set the bool field to true or false before, the exception is not thrown.

This is the german exception text: "An exception was caught during the execution of an action query: Der Wert NULL kann in die bool_XXX-Spalte, blablabla-Tabelle, nicht eingefügt werden. Die Spalte lässt NULL-Werte nicht zu. Fehler bei INSERT. Die Anweisung wurde beendet.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."

If I check the bool-field before calling the "Save" method, the bool value is set to false by default. But it seems that instead of false LLBLGen tries to write NULL.

Why is that?

(using v2.0 and self servicing)

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Sep-2006 15:14:37   

Well LLBLGen Pro does not try to write anything to this field (with regard to your posted query).

Since the field is not recognized to have a dirty value (IsChanged == false). So it simply ignores it.

So either you set a default value of 0 in the database (my favorite solution) Or you set the field IsChanged to true, and The Entity.IsDirty to true also.

Sokon1
User
Posts: 97
Joined: 17-Jul-2006
# Posted on: 07-Sep-2006 15:16:50   

Thanks for your answer simple_smile