1

I'm trying to insert a row in to one of my tables, so I look over the web to find an example for using the DATACONTEXT and found this one:

protected void buttonSave_Click(object sender, EventArgs e)
{
  using (NorthwindDataContext context = new NorthwindDataContext())
  {
    Customer customer = new Customer
    {
      CustomerID = textBoxCustomerID.Text,
      CompanyName = textBoxCompanyName.Text,
      ContactName = textBoxCustomerName.Text,
      ContactTitle = textBoxTitle.Text,
      Address = textBoxAddress.Text,
      City = textBoxCity.Text,
      Region = textBoxRegion.Text,
      PostalCode = textBoxPostalCode.Text,
      Country = textBoxCountry.Text,
      Phone = textBoxPhone.Text,
      Fax = textBoxFax.Text
    };
    context.Customers.InsertOnSubmit(customer);
    context.SubmitChanges();
  }
}

but when I try to use it and write : context.Guides. - now I can't see the InsertOnSubmit method.. does some one know why?

thanks, yoni.

Sander Rijken
  • 21,376
  • 3
  • 61
  • 85
yoni
  • 47
  • 1
  • 2
  • 7

2 Answers2

1

If you are using a LINQ-to-SQL Classes model (*.dbml), the Guides table must appear in the designer. Otherwise, the Guides class must descend from System.Data.Linq.Mapping.MetaTable.

Neil T.
  • 3,308
  • 1
  • 25
  • 30
-1

Guides must be an object that doesn't implement the InsertOnSubmit method.

Randy Minder
  • 47,200
  • 49
  • 204
  • 358