当前上下文中不存在
为什么我的这行代码显示错误
var searchUser = from accnt_user in dbo.Accounts
where accnt_user == txtUser.Text &&
accnt_Pass == txtPassword.Text
select accnt_user;
错误 2 名称“accnt_Pass”在当前上下文中不存在 C:\Users\John\documents\visual studio 2010\Projects\PAS\PAS\Login.cs 39 66 PAS
错误 1 当前上下文中不存在名称“dbo”C:\Users\John\documents\visual studio 2010\Projects\PAS\PAS\Login.cs 38 49 PAS
但我已经将我的数据上下文链接到它
DataClasses1DataContext myDbContext = new DataClasses1DataContext(dbPath);
并且我的 DataClasses1DataContext 已经有这行代码
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Accounts")]
public partial class Account : INotifyPropertyChanging, INotifyPropertyChanged
注意:我没有在数据上下文中添加所有代码,因为它很长
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试这样,因为
accnt_user
这将是 Accounts 的对象,因此您需要使用.
运算符访问其所有成员try like this, as
accnt_user
this will be the object of Accounts, so you need to access its all member by using.
operatorr您没有在查询中使用上下文。此外,所有列名称都必须以为源表或联接定义的别名作为前缀(与 SQL 不同,如果列在查询中的表或视图集中是唯一的,则可以省略前缀)。
将代码更改为如下所示:
这本质上相当于此 SQL:
You aren't using the context in your query. Also, all column names must be prefixed by the alias defined for the source table or join (unlike SQL, where you can omit the prefix if the column is unique across the set of tables or views in the query).
Change your code to look like this:
This is essentially equivalent to this SQL: