我正在尝试将 Datacontext 接口重命名为 NutshellContext,但我一直在标题中写入此错误。顺便说一下,这是完整的代码。错误在于 main 函数之后的第一个代码。我的数据库表似乎是正确的语法。
[Table (Name = "Customer")]
public class Customer
{
[Column(IsPrimaryKey = true)]
public int ID;
[Column (Name = "Name")]
public string Name;
}
class NutshellContext : DataContext // For LINQ to SQL
{
public Table<Customer> Customers
{
get { return GetTable<Customer>(); }
}
}
class Program
{
static Main()
{
var context = new NutshellContext(@"Server=.\SQLEXPRESS;Database=master;Trusted_Connection=True;");
Console.WriteLine(context.Customers.Count());
}
}