UpdateMulti question

Posts   
 
    
pls2917
User
Posts: 11
Joined: 26-May-2009
# Posted on: 29-Jul-2009 07:58:00   

Am I missing something obvious in how UpdateMulti works?

I have an entity retrieved like this:

  DrugUnitEntity newDrugValues = new DrugUnitEntity("100001");

At this point, DepotID property of the template entity is "01".

Then I update the value as a template for the save:

  newDrugValues.DepotID = null;

            DrugUnitCollection saveDrugs = new DrugUnitCollection();
            saveDrugs.UpdateMulti(newDrugValues, DrugUnitFields.ID == drugUnitIDsToUpdate);

I find that my records will not have the DepotID value updated to null in the database unless I do this instead of a direct property assignment:

   newDrugValues.Fields["DepotID"].CurrentValue = null;

What am I missing?

version info: SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll: 2.6.8.1114 SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll: 2.6.9.703

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 29-Jul-2009 08:38:28   

After setting the field to null, what's the value of:

newDrugValues.Fields["DepotID"].IsChanged
pls2917
User
Posts: 11
Joined: 26-May-2009
# Posted on: 29-Jul-2009 17:50:31   

IsChanged is false after setting it to null

Setting to some other value such as "99" makes IsChanged true.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Jul-2009 05:33:20   

Must be that the field isn't generated as nullable. Does the field accept NULL at Database?

David Elizondo | LLBLGen Support Team
pls2917
User
Posts: 11
Joined: 26-May-2009
# Posted on: 30-Jul-2009 05:45:38   

Ah, that's the key. Thanks!

Yes the db accepts it, but since the entity was generated from a view it didn't pick up the correct settings for nullable. Manually setting them in the designer solves it.