Linq to sql LinqToSql-“一个;在提交时插入“;
我正试图在我的一个表中插入一行, 因此,我在网上查找了一个使用DATACONTEXT的示例,并找到了以下示例:Linq to sql LinqToSql-“一个;在提交时插入“;,linq-to-sql,insertonsubmit,Linq To Sql,Insertonsubmit,我正试图在我的一个表中插入一行, 因此,我在网上查找了一个使用DATACONTEXT的示例,并找到了以下示例: protected void buttonSave_Click(object sender, EventArgs e) { using (NorthwindDataContext context = new NorthwindDataContext()) { Customer customer = new Customer { CustomerID
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.指南必须是未实现InsertOnSubmit方法的对象 如果您使用的是LINQ到SQL类模型(*.dbml),则向导表必须显示在设计器中。否则,Guides类必须从System.Data.Linq.Mapping.MetaTable降级Guides属性的类型是什么?