[英]Wp7 dataconnectivity error
I have a table emp2 which contains Empid EmpName Salary 我有一个表emp2,其中包含Empid EmpName Salary
i passed a linq from c in emp where empname=="ss" select c now i want to show the empid of that empname but the code is showing error all arround at linq ERROR ::: Emp2.EmpName' has no supported translation to SQL. 我在emp中从c传递了一个linq,其中empname ==“ ss”选择c现在我想显示该empname的Empid,但是代码在linq处都显示错误ERROR ::: Emp2.EmpName'没有支持的翻译SQL。 at countrylist=query.tolist();
在countrylist = query.tolist();
private const string ConnectionString = "isostore:/Emp1.sdf"; 私有常量字符串ConnectionString =“ isostore:/Emp1.sdf”;
[Table(Name = "Emp")]
public class Emp2
{
[Column(IsPrimaryKey = true, IsDbGenerated = true)]
public int EmpId
{
get;
set;
}
public string EmpName
{
get;
set;
}
public int Salary
{
get;
set;
}
}
public MainPage()
{
InitializeComponent();
using (CountryDataContext context = new CountryDataContext(ConnectionString))
{
if (!context.DatabaseExists())
{
context.CreateDatabase();
}
else
{
MessageBox.Show("Employee table exist already");
}
}
}
private IList<Emp2> getcountry()
{
IList<Emp2> countryList = null;
using (CountryDataContext context = new CountryDataContext(ConnectionString))
{
IQueryable<Emp2> query = from c in context.Emp where c.EmpName=="ss" select c;
countryList = query.ToList();
}
return countryList;
}
public class CountryDataContext : DataContext
{
public CountryDataContext(string connectionString)
: base(connectionString)
{
}
public Table<Emp2> Emp
{
get
{
return this.GetTable<Emp2>();
}
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
IList<Emp2> emp= this.getcountry();
foreach (Emp2 a in emp)
{
MessageBox.Show(a.EmpId.ToString());
}
您尚未向EmpName
属性添加属性以指示它是一列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.