forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule1.vb
54 lines (40 loc) · 1.35 KB
/
module1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.Linq
Module Module1
Sub Main()
' <Snippet1>
Dim db As New Northwnd("c:\northwnd.mdf")
Dim dlo As DataLoadOptions = New DataLoadOptions()
dlo.AssociateWith(Of Customer)(Function(c As Customer) _
c.Orders.Where(Function(p) p.ShippedDate <> DateTime.Today))
db.LoadOptions = dlo
Dim custOrderQuery = _
From cust In db.Customers _
Where cust.City = "London" _
Select cust
For Each custObj In custOrderQuery
Console.WriteLine(custObj.CustomerID)
For Each ord In custObj.Orders
Console.WriteLine("{0}{1}", vbTab, ord.OrderDate)
Next
Next
' </Snippet1>
Console.ReadLine()
End Sub
Sub x()
' <Snippet2>
Dim db As New Northwnd("c:\northwnd.mdf")
Dim dlo As DataLoadOptions = New DataLoadOptions()
dlo.LoadWith(Of Customer)(Function(c As Customer) c.Orders)
db.LoadOptions = dlo
Dim londonCustomers = _
From cust In db.Customers _
Where cust.City = "London" _
Select cust
For Each custObj In londonCustomers
Console.WriteLine(custObj.CustomerID)
Next
' </Snippet2>
End Sub
End Module