[英]Insert Records in multiple table which are dependent on primary / foreign key using Linq-to-SQL
[英]LINQ-to-SQL get Primary Key from Table
我有一些麻烦搞清楚为什么我在使用这段代码时收到NullReferenceException
:
entityCustomer customer = new entityCustomer {
firstName = txtFName.Text,
lastName = txtLName.Text,
homeAddress = txtAddress.Text,
phoneNumb = txtPhone.Text,
emailAddress = txtEmail.Text
};
custTable.InsertOnSubmit(customer);
dc.SubmitChanges();
我在InsertOnSubmit
上得到错误。 这是我的实体类:
我试过关注https://stackoverflow.com/a/788402/2416047 ,你可以看到,但仍然没有运气。
我究竟做错了什么?
您的custTable
变量,参数,属性或字段为null。 在调用任何成员之前,您需要为其分配值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.