I have the following code to create multiple WithPaths
Public Enum PrefetchItemEnum
None
Attendance
StudActive
StudData
End Enum
Public Shared Function FetchEntity(ByVal studentId As String, ByVal prefetchItem1 As PrefetchItemEnum, ByVal prefetchItem2 As PrefetchItemEnum, ByVal prefetchItem3 As PrefetchItemEnum) As StudentMstrEntity
Dim meta As New Linq.LinqMetaData(New DataAccessAdapter)
Dim q = From d In meta.StudentMstr Where d.StudentId = studentId Select d
If prefetchItem1 = PrefetchItemEnum.Attendance Then
q = q.WithPath(New PathEdge(Of AttendanceEntity)(StudentMstrEntity.PrefetchPathAttendance))
End If
If prefetchItem2 = PrefetchItemEnum.StudActive Then
q = q.WithPath(New PathEdge(Of StudActiveEntity)(StudentMstrEntity.PrefetchPathStudActive))
End If
If prefetchItem3 = PrefetchItemEnum.StudData Then
q = q.WithPath(New PathEdge(Of StudDataEntity)(StudentMstrEntity.PrefetchPathStudData))
End If
Dim c = q.ToEntityCollection(Of StudentMstrEntity)()
If c.Count >= 0 Then Return c(0)
Return Nothing
End Function
The .ToEntityCollection is an extension that Gabe Nodland(sp?) wrote:
<System.Runtime.CompilerServices.Extension()> _
Public Function ToEntityCollection(Of t As EntityBase2)(ByVal q As IQueryable) As EntityCollection(Of t)
If Not TypeOf q Is ILLBLGenProQuery Then
Throw New ApplicationException("Only ILLBLGenProQuery may be outputed as EntityCollections")
End If
Return CType(q, ILLBLGenProQuery).Execute(Of EntityCollection(Of t))()
End Function
But, it seems like it only does one of the WithPaths not the ones selected.
Am I doing the WithPath logic correctly?
Thanks