真的坚持这个。逻辑似乎与我在其余应用程序中使用的任何其他Linq to Entity逻辑不同。我只是使用Linq to Entity将数据写入名为FAQ的表中。但是我得到了消息BC30311:Type of Type' faq'无法转换为常见问题解答'。我无法弄清楚它意味着什么价值。
Dim objQuestion As TextBox = gvDetails.FooterRow.FindControl("txtFooterQuestion")
Dim objAnswer As TextBox = gvDetails.FooterRow.FindControl("txtFooterAnswer")
Dim objCategory As TextBox = gvDetails.FooterRow.FindControl("txtFooterCategory")
Using DBContext As New fundmatrixEntities
Dim queryFAQ = DBContext.FAQs
Dim oFAQ As New FAQ
queryFAQ.Add(oFAQ)
oFAQ.FAQId = 5
oFAQ.Question = objQuestion.Text
oFAQ.Answer = objAnswer.Text
oFAQ.Category = objCategory.Text
oFAQ.DateCreated = Date.Now
oFAQ.DateUpdated = Date.Now
Try
DBContext.SaveChanges()
BindEmployeeDetails()
lblresult.ForeColor = Drawing.Color.Green
lblresult.Text = "details inserted successfully"
Catch ex As Exception
lblresult.Text = "There was problem inserting the FAQ!"
lblresult.ForeColor = Drawing.Color.Red
End Try
End Using