1

我试图在我的一个表中插入一行,所以我在网上查找了一个使用 DATACONTEXT 的示例并找到了这个:

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();
  }
}

但是当我尝试使用它并编写时:context.Guides.-现在我看不到该InsertOnSubmit方法..有人知道为什么吗?

谢谢,尤尼。

4

2 回答 2

1

如果您使用的是 LINQ-to-SQL 类模型 (*.dbml),则 Guides 表必须出现在设计器中。否则,Guides 类必须从System.Data.Linq.Mapping.MetaTable 继承

于 2010-01-03T18:20:50.233 回答
-1

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

于 2010-01-01T14:17:55.907 回答