使用此代码:
var locationsInDB = from TaSLs_SQLCELocationDataDefinition location in
TaSLs_SQLCELocation.TaSLs_SQLCELocationDataDefinitions
where location.SavedToCloud = false
select location;
......我明白了,
"*非静态字段、方法或属性'TaSLS_PhoneApp.MainPage.TaSLs_SQLCELocation'需要对象引用*"
我在一个单独的类中声明了 TaSLs_SQLCELocationDataContext:
public class TaSLs_SQLCELocationDataContext : DataContext
{
public static string DBConnectionString = "Data Source=isostore:/gr8GooglyMoogly.sdf";
public TaSLs_SQLCELocationDataContext(string connectionString)
: base(connectionString)
{ }
public Table<TaSLs_SQLCELocationDataDefinition> TaSLs_SQLCELocationDataDefinitions;
}
我不能将 TaSLs_SQLCELocationDataContext 设为静态,因为它实现了 DataContext
如果我像这样实例化该类:
TaSLs_SQLCELocationDataContext tsldc = new TaSLs_SQLCELocationDataContext();
var locationsInDB = from TaSLs_SQLCELocationDataDefinition location in
tsldc.TaSLs_SQLCELocationDataDefinitions
where location.SavedToCloud = false
select location;
...然后我得到,
“*'TaSLS_PhoneApp.TaSLs_Data.TaSLs_SQLCELocationDataContext' 不包含采用 0 个参数的构造函数*”
它期待什么论据?