开发者

LinqToSql - "insert on submit"

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 = textBoxCompanyNam开发者_运维知识库e.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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜