我想在我的表之一插入一行, 所以我期待在網上找到使用DataContext的一個例子,這個發現之一:LinqToSql - 「插上提交」
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
方法.. 確實有人知道爲什麼嗎?
謝謝, yoni。
指南屬性的類型是什麼? – 2010-01-01 13:05:38