0
我認爲你可以用linq做到這一點,但它總是拋出一個外鍵錯誤,並且ContactType.id爲0.是否需要在插入新的ContactType後調用SubmitChanges,我缺少基本的東西?linq to sql @identity外鍵插入提交
Dim ct As New ContactType
ct.name = "supervisor"
db.ContactTypes.InsertOnSubmit(ct)
Dim c As New Contact
c.ContactTypeId = ct.id
c.first_name = "fname"
c.last_name = "lname"
db.contacts.InsertOnSubmit(c)
db.SubmitChanges()