views:

85

answers:

2

Running the latest version of SubSonic (3.0.0.3). Retreiving a single record, making one field change and calling .Save results in a null reference exception in the code below:

public void Update(IDataProvider provider){

        if(this._dirtyColumns.Count>0)
            _repo.Update(this,provider);
        OnSaved();
   }

My code to create this exception is simply:

                DAL.MY_QUEUE l_l_itmEngageItem = MY__QUEUE.SingleOrDefault(x => x.id == each.id);
                l_l_itmItem.date_submitted = DateTime.Now;
                l_l_itmItem.Update();

Anyone have some insight? 2.0 never gave me an issue. Any help very appreciated.

+1  A: 

It doesn't even look like you're retrieving and updating the same item. You're retrieving into l_l_itmEngageItem and then updating a field on l_l_itmItem, which you then call Update() on.

I'm guessing that l_l_itemItem hasn't been initialized to anything that's actually in the database yet.

Perhaps the problem is your variable naming ;)

womp
+1  A: 

I experienced the exact same scenario. I was able to insert, but not update.

The cause, I found, was that a primary key was not set on the table. Once the primary key was set, I was able to update.

Anonymouse