问题
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:
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.
回答2:
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 ;)
来源:https://stackoverflow.com/questions/1166675/subsonic-3-0-0-3-crash