Can not set entity value to NULL

Posts   
 
    
Wurox
User
Posts: 5
Joined: 26-Aug-2007
# Posted on: 26-Aug-2007 23:41:00   

Hello,

I'am using LLBLGenProDataSource control for SelfServicing and binding it to a Collection class generated by LLBL Generator v2. The Entity is generated mapped on a View from SQL Server 2005. When I try to update a field from that entity and set it to null it doesn't change. Note that when I try to change it's value to anything else but null it works fine. When generating I specified that the colum is nullable. The column in the database is nullable as well. Code: // getting the entity based on a primary key ViewTvrtka_Entity ent = new ViewTvrtka_Entity(734); ent.SetNewFieldValue((int)ViewTvrtka_FieldIndex.TvrOdgovornaOsoba, null);

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Aug-2007 06:00:58   

Hi Wurox, What type is the field you are updating? What is the LLBLGenPro exact version you are using? When you update the field, it simply doesn't change or an exception is raised?

David Elizondo | LLBLGen Support Team
Wurox
User
Posts: 5
Joined: 26-Aug-2007
# Posted on: 27-Aug-2007 09:21:08   

The filed for update is of type string (varchar in the DB). Version of LLBLgen is 2.0. The exception is not raised and the value is not changed neither in memory neither in the DB (after commit statement).

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Aug-2007 09:42:46   

Which runtime library version are you using? (check the following thread, to know how to get the RTL version: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7722)

What was the field value before you set it to null?, if the entity field's value was initially null, then the value won't change when you attempt to set it to null, then nothing for this feild would be generated in the Update query.

Wurox
User
Posts: 5
Joined: 26-Aug-2007
# Posted on: 27-Aug-2007 13:14:53   

Thanks for quick reply.

I am using following versions of LLBLGen: Version : 2.0.0.0 Final Runtime library version: 2.0.0.60803

The problem is that when I retrive an entity from the database it value in the field is a string (for example „andy“). Then when I try to set it to null, I can't. During debugging I noticed that the line of code:

ent.SetNewFieldValue((int)ViewTvrtka_FieldIndex.TvrOdgovornaOsoba, null);

doesn' set the value in the entity to null. It is still „andy“ in memory, and of course when I try to save it to DB the change is not commited to DB.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 27-Aug-2007 19:03:37   

try checking the IsNull property value of that entity in your llblgen project (llbl's designer). Maybe you've changed the nullable value in your database and you forgot to regen o refresh the catalog.

Wurox
User
Posts: 5
Joined: 26-Aug-2007
# Posted on: 28-Aug-2007 08:38:27   

As I said in my first post, null value is allowed in the database, and I selected nullable for that column when I generated the catalog. I've regenerated it several times before I wrote this post. If the null value was not allowed in the database the database should throw an exception. If null value is not allowed in the generated catalog wouldn't it also throw an exception? There is some problem with updating updatable views. I've created an updatable view in the database, and generated it from selecting „Add new Entities Mapped on Views from catalog(s)..“. Then I've binded the collection to the LLBL GenDataSource for self servicing. Has anybody tryed this? Did you have any problems?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Aug-2007 12:31:23   

We need your help in the following:

1- You have a year old version of LLBLGen Pro runtime libraries, would you please try out the latest version and check if the problem still exists?

2-

The Entity is generated mapped on a View from SQL Server 2005.

Can you confirm that this issue is not happening with Entities mapped on a table

Wurox
User
Posts: 5
Joined: 26-Aug-2007
# Posted on: 29-Aug-2007 09:10:06   

I have downloaded the 2.5 version and it works fine now. Thanks for your replys. Note the same thing did not happend on entities mapped on tables, just views.

Thanks