我想在我的表之一插入一行, 所以我期待在网上找到使用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