指定演员表无效。在c#中使用linq-to-sql类时出错 [英] Specified cast is not valid. error in using linq-to- sql class in c#
本文介绍了指定演员表无效。在c#中使用linq-to-sql类时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用linq-to-sql将我的Web应用程序连接到sql server ...我的代码是。
EmployeeCheckoutDataContext db = new EmployeeCheckoutDataContext();
EmployeeDetail ed = null;
I am using linq-to-sql to connect my web application to sql server... my code is.
EmployeeCheckoutDataContext db = new EmployeeCheckoutDataContext();
EmployeeDetail ed = null;
protected void Button1_Click(object sender, EventArgs e)
{
ed = (from a in db.GetTable<EmployeeDetail>()
where (a.Name == "xyz")
select a).SingleOrDefault<EmployeeDetail>();
Label1.Text = ed.EmployeeNo;
}
因为我编译代码,我得到的错误是指定演员表无效。 at code
as i compile the code, the error i get is "Specified cast is not valid." at code
ed = (from a in db.GetTable<EmployeeDetail>()
where (a.Name == "xyz")
select a).SingleOrDefault<EmployeeDetail>();
i也试过var类型。我完全不知道这是怎么回事..任何帮助??
i had also tried with var type. i am completely blank to how this is happening.. any help??
推荐答案
我更新了datacontext,现在它的工作......
i updated datacontext and now its working...
这篇关于指定演员表无效。在c#中使用linq-to-sql类时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文