私は最初にEF4コードで構築されたDBを持っています、ここに2つのモデルがあります:
Public Class HvacAudit
Public Property HvacAuditID As Integer
Public Overridable Property HvacAuditPictures As IEnumerable(Of HvacAuditPicture)
... other properties
End Class
Public Class HvacAuditPicture
Public Property HvacAuditPictureID As Integer
Public Property HvacAuditID As Integer
Public Overridable Property HvacAudit As HvacAudit
... other properties
End Class
データベースからHvacAuditレコードをプルすると、HvacAuditPicturesがありません。写真を直接引っ張ってもそこにあります。検討
context.HvacAudits.Where(Function(hva) hva.HvacAuditID = 1).HvacAuditPictures Is Nothing 'evaluates true
context.HvacAuditPictures.Where(Function(p) p.HvacAuditID = 1).Count() 'is currently 20
これが私のコンテキストクラスです:
Public Class EfContext
Inherits DbContext
Implements IDataSource
Public Property HvacAudits As IDbSet(Of HvacAudit) Implements IDataSource.HvacAudits
Public Property Vendors As IDbSet(Of Vendor) Implements IDataSource.Vendors
Public Property HvacAuditPictures As IDbSet(Of HvacAuditPicture) Implements IDataSource.HvacAuditPictures
Public Property Sites As IDbSet(Of Site)
Public Property Markets As IDbSet(Of Market)
Public Sub SaveChanges1() Implements Domain.DataSource.IDataSource.SaveChanges
SaveChanges()
End Sub
End Class