我正在尝试使用LinqPad使用Linq查询数据,更新它并将更改提交回数据库。很抱歉,myobject.Email
Email
字段不存在,我收到错误消息。为什么我无法访问Email
字段?
var myobject = from u in Users where u.Email == "myolde@email.com" select u;
myobject.First();
myobject.Email = "mynew@mail.com";
SubmitChanges();
答案 0 :(得分:1)
您正在尝试访问集合的字段。您可能想要访问第一个对象:
var myObject = from u in Users where u.Email == "myolde@email.com" select u;
var user = myobject.First();
user.Email = "mynew@mail.com";
SubmitChanges();