Tuesday, 10 September 2013

Error 2 '' does not contain a constructor that takes 1 arguments, (Topic: typed Context)

Error 2 '' does not contain a constructor that takes 1 arguments, (Topic:
typed Context)

I am trying to rename the Datacontext interface to NutshellContext but i
kept getting this error written in my title. Here is the full code by the
way. The error lies in the first code after the main function. My database
table seems to be correct syntax.
[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());
}
}

No comments:

Post a Comment