Subsonic 3.0.0.3 Crash

戏子无情 提交于 2019-12-11 02:17:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!