我已经编写了如下的 linq 查询:
NorthwindContext context = SqlCE;
var query = context.Destinations.Where(i => i.Id >= 1).Select(i => new {
id = i.Id,
name = i.Destination
}).ToArray();
public NorthwindDataContext SqlCE
{
get
{
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
string connectionString = @"Data Source=|DataDirectory|\Database1.mdf";
return new NorthwindDataContext(connectionString);
}
}
我已连接到 sqlserver northwind.mdf 文件。我在表中有值,我仍然得到空引用异常。我该如何纠正这一点。如何在查询中获取值。
问候