entity framework - linq query to update boolean field in table with where condition -


i trying update 1 field in db of type boolean. table structure

usr_id int false
usr_fname nvarchar(50)
usr_lname nvarchar(50)
usr_username nvarchar(50)
usr_password nvarchar(max)
usr_email nvarchar(50)
usr_pwdresetstatus bit

this trying

public int forgotpassword(string username, string emailid)       {           var result = db.tm_usr_usermaster.where(m => m.usr_username == username && m.usr_email==emailid).select(m => m.usr_isactive).singleordefault();           bool isactive = convert.toboolean(result);           if(isactive==false)           {             //update query           }           else           {            } 

i receiving parameters username , email id if both matches pwdresetstatus should updated true. can write sql equivalent here update tablename set pwdresetstatus=true usr_username==username && usr_email==emailed. have difficult times go ahead

i tried

tm_usr_usermaster users = db.tm_usr_usermaster.firstordefault(x => x.usr_email==emailid && x.usr_username==username);               users.usr_pwdresetstatus = true;               db.savechanges(); 

and working fine. thank stephen


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -