Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误2'';不包含接受1个参数的构造函数(主题:Linq to SQL中的类型化上下文)_C#_Sql_Sql Server_Linq - Fatal编程技术网

C# 错误2'';不包含接受1个参数的构造函数(主题:Linq to SQL中的类型化上下文)

C# 错误2'';不包含接受1个参数的构造函数(主题:Linq to SQL中的类型化上下文),c#,sql,sql-server,linq,C#,Sql,Sql Server,Linq,我试图将Datacontext接口重命名为NutshellContext,但我一直在标题中写入此错误。顺便说一下,这是完整的代码。错误出现在主函数后的第一个代码中。我的数据库表似乎语法正确 [Table (Name = "Customer")] public class Customer { [Column(IsPrimaryKey = true)] public int ID; [Column (Name = "Name")] public string Nam

我试图将Datacontext接口重命名为NutshellContext,但我一直在标题中写入此错误。顺便说一下,这是完整的代码。错误出现在主函数后的第一个代码中。我的数据库表似乎语法正确

[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());
    }
}
[表(Name=“客户”)]
公共类客户
{
[列(IsPrimaryKey=true)]
公共int ID;
[列(Name=“Name”)]
公共字符串名称;
}
类NutshellContext:DataContext//For LINQ to SQL
{
公众餐桌顾客
{
获取{return GetTable();}
}
}
班级计划
{
静态Main()
{
var context=new NutshellContext(@“Server=。\SQLEXPRESS;Database=master;Trusted_Connection=True;”);
Console.WriteLine(context.Customers.Count());
}
}

NutshellContext类不包含显式构造函数,因此,该类的默认构造函数是无参数构造函数。要使代码正常工作,您需要创建具有以下签名的构造函数:

public NutshellContext(string connectionString)
{
    //Your logic
}
这是关于c的什么话题?如果可能的话,你能给我一个教程的链接吗?看看这个链接: