我正在使用open acces orm,我需要一种简单的方法来获取父实体信息并自定义加载相关的子信息。我的意思是,当我要求订单时,我只想要订单信息,并能够加载或不加载订单信息。
如果我有:
Public Class Order
Public Property Number As Long
Public Property Description As String
Public Property OrderLines as List(of OrderLines) = new List(of OrderLines)
End Class
如果我想要的话,我该怎么办:
Dim e as new EntitiesModel()
Dim q as Order = (from c in e.Orders
where c.Number = 5
select c).FirstOrDefault()
我需要查询只是为了检索订单数据而不是OrderLines,这似乎是OA默认执行的操作。
编辑:我已经尝试过了:
Using dbcontext As New EntitiesModel()
Dim fetchStrategy As New FetchStrategy()
dbcontext.FetchStrategy = fetchStrategy
Dim q As Order
q = (From c In dbcontext.Orders
Where c.PK_Order = 79
Select c).FirstOrDefault
For Each olFound In q.OrderLines
Dim i As Integer
Console.WriteLN(olFound.Description&VbNewLine)
Next
End Using
我仍然收到OrderLines数据,我不需要那些数据。大部分telerik的例子都是要加载相关数据,但我想要相反。有没有办法指定我想要或不想做?我希望明确:/