Being new to LINQ, I created a couple queries and would like to combine them into one, but I am not sure how to do it. Here they are:
var u = dc.Users.Where(w => w.UserName == userName).SingleOrDefault();
var m = dc.Memberships.Where(w => w.UserId == u.UserId).SingleOrDefault();
m.PasswordQuestion = securityQuestion;
m.PasswordAnswer = securityAnswer;
dc.SubmitChanges();
dc.Users
is the aspnet_Users
table
dc.Membership
is the aspnet_Membership
table
Also, What is the difference between SingleOrDefault
and FirstOrDefault
?