Wp7 数据连接错误
本文关键字:错误 连接 数据 Wp7 | 更新日期: 2023-09-27 18:33:47
>我有一个表格 emp2 包含 empid empName 薪水
我在 emp 中从 C 传递了一个 linq,其中 empname=="ss" 选择 C现在我想显示该 empname 的 empid但是代码在 LINQ 上显示所有错误错误 ::: Emp2.EmpName' 不支持转换为 SQL。在 countrylist=query.tolist();
私有常量字符串 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
属性添加属性以指示它是列。