实体未将更新值保存到db

时间:2016-08-23 14:26:18

标签: c# asp.net entity-framework

我正在尝试将db的值增加1,但由于某种原因它没有保存到db中

 public void updateLockedOutCount(string email)
 {
        int count = 1;
        tblPortalUser q = portalEntities.tblPortalUsers.Where(w => w.EmailAddress == email).FirstOrDefault();
        q.loginAttempts = q.loginAttempts + count;
        q.isActive = false;
        _dal.portalEntities.Entry(q).State = System.Data.Entity.EntityState.Modified;

        _dal.portalEntities.SaveChanges();
        _dal.portalEntities.Entry(q).Reload();
}

门户网站实体只是我的上下文属性

public portalEntities _portalEntities;
    public portalEntities portalEntities
    {
        get
        {
            if (_portalEntities == null)
            {
                try
                {
                    _portalEntities = new portalEntities();
                }
                catch (Exception ex)
                {
                }
            }

            return _portalEntities;
        }
    }

0 个答案:

没有答案