set field to null

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 06-Jun-2006 16:04:05   

Hi,

How do I get the following code to set the field to null without putting 'entity.IsNew = false;' after 'SetNewFieldValue'?

            JobEntity entity = new JobEntity();
            entity.JobId = 2;
            entity.IsNew = false;
            entity.SetNewFieldValue("JobTypeId", null);

            DataAccessAdapter adapter = new DataAccessAdapter();
            adapter.SaveEntity(entity);

With this code nothing happens at all. If I put IsNew = false after the SetNewFieldValue then it works.

Cheers, I.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 06-Jun-2006 18:05:51   

Got it with...

entityInstance.Fields[propertyName].IsChanged = true;

..before the property set.