我有这段代码:
Public Class myclass
....
Private cont As MyentEntities
.....
.....
Public Sub New( ByRef cnx As MyentEntities)
.....
cont = cnx
.....
End Sub
Public Sub test
.....
If cont.mytable1.Count=1 then
.....
end if
End Sub
End class
'在我的主要表格上:
.......
Dim E1 as MyEntEntities
Dim m1 as myclass
Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs)
Handles Me.Load
E1=New MyentEntities
m1=new MyClass(E1)
Fill_entity()
........
End Sub
Private sub fill_entity
E1.MyTable1.Tolist
....
End sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
Handles Button1.Click
m1.test
End Sub
当我点击按钮时,出现错误:
....“MyTable1”类型的实体在上下文中不存在。
但是我用ByRef通过了E1?
怎么了?
谢谢!