LINQ To SQL Samples - Object Loading |
This sample demonstrates how navigating through relationships in retrieved objects can end up triggering new queries to the database if the data was not requested by the original query.
Public Sub LinqToSqlObject01()
Dim custs = From c In db.Customers _
Where c.City = "Sao Paulo" _
Select c
For Each cust In custs
For Each ord In cust.Orders
Console.WriteLine("CustomerID {0} has an OrderID {1}.", cust.CustomerID, ord.OrderID)
Next
Next
End Sub
Result:
CustomerID COMMI has an OrderID 10290.
CustomerID COMMI has an OrderID 10466.
CustomerID COMMI has an OrderID 10494.
CustomerID COMMI has an OrderID 10969.
CustomerID COMMI has an OrderID 11042.
CustomerID FAMIA has an OrderID 10347.
CustomerID FAMIA has an OrderID 10386.
CustomerID FAMIA has an OrderID 10414.
CustomerID FAMIA has an OrderID 10512.
CustomerID FAMIA has an OrderID 10581.
CustomerID FAMIA has an OrderID 10650.
CustomerID FAMIA has an OrderID 10725.
CustomerID QUEEN has an OrderID 10372.
CustomerID QUEEN has an OrderID 10406.
CustomerID QUEEN has an OrderID 10487.
CustomerID QUEEN has an OrderID 10637.
CustomerID QUEEN has an OrderID 10659.
CustomerID QUEEN has an OrderID 10704.
CustomerID QUEEN has an OrderID 10728.
CustomerID QUEEN has an OrderID 10786.
CustomerID QUEEN has an OrderID 10868.
CustomerID QUEEN has an OrderID 10913.
CustomerID QUEEN has an OrderID 10914.
CustomerID QUEEN has an OrderID 10961.
CustomerID QUEEN has an OrderID 11068.
CustomerID TRADH has an OrderID 10292.
CustomerID TRADH has an OrderID 10496.
CustomerID TRADH has an OrderID 10606.
CustomerID TRADH has an OrderID 10830.
CustomerID TRADH has an OrderID 10834.
CustomerID TRADH has an OrderID 10839.
This sample demonstrates how to use Including to request related data during the original query so that additional roundtrips to the database are not required later when navigating through the retrieved objects.
Public Sub LinqToSqlObject02()
Dim db2 = New NorthwindDataContext(My.Settings.NORTHWINDConnectionString1)
Dim ds = New DataLoadOptions()
ds.LoadWith(Of Customer)(Function(p) p.Orders)
db2.LoadOptions = ds
Dim custs = From c In db.Customers _
Where c.City = "Sao Paulo" _
Select c
For Each cust In custs
For Each ord In cust.Orders
Console.WriteLine("CustomerID {0} has an OrderID {1}.", cust.CustomerID, ord.OrderID)
Next
Next
End Sub
Result:
CustomerID COMMI has an OrderID 10290.
CustomerID COMMI has an OrderID 10466.
CustomerID COMMI has an OrderID 10494.
CustomerID COMMI has an OrderID 10969.
CustomerID COMMI has an OrderID 11042.
CustomerID FAMIA has an OrderID 10347.
CustomerID FAMIA has an OrderID 10386.
CustomerID FAMIA has an OrderID 10414.
CustomerID FAMIA has an OrderID 10512.
CustomerID FAMIA has an OrderID 10581.
CustomerID FAMIA has an OrderID 10650.
CustomerID FAMIA has an OrderID 10725.
CustomerID QUEEN has an OrderID 10372.
CustomerID QUEEN has an OrderID 10406.
CustomerID QUEEN has an OrderID 10487.
CustomerID QUEEN has an OrderID 10637.
CustomerID QUEEN has an OrderID 10659.
CustomerID QUEEN has an OrderID 10704.
CustomerID QUEEN has an OrderID 10728.
CustomerID QUEEN has an OrderID 10786.
CustomerID QUEEN has an OrderID 10868.
CustomerID QUEEN has an OrderID 10913.
CustomerID QUEEN has an OrderID 10914.
CustomerID QUEEN has an OrderID 10961.
CustomerID QUEEN has an OrderID 11068.
CustomerID TRADH has an OrderID 10292.
CustomerID TRADH has an OrderID 10496.
CustomerID TRADH has an OrderID 10606.
CustomerID TRADH has an OrderID 10830.
CustomerID TRADH has an OrderID 10834.
CustomerID TRADH has an OrderID 10839.
This sample demonstrates how navigating through relationships in retrieved objects can end up triggering new queries to the database if the data was not requested by the original query.
Public Sub LinqToSqlObject03()
Dim custs = From c In db.Customers _
Where c.City = "London" _
Select c
For Each cust In custs
For Each ord In cust.Orders
For Each orderDetail In ord.Order_Details
Console.WriteLine("CustomerID {0} has an OrderID {1} with ProductID {2} that has name {3}.", _
cust.CustomerID, ord.OrderID, orderDetail.ProductID, orderDetail.Product.ProductName)
Next
Next
Next
End Sub
Result:
CustomerID AROUT has an OrderID 10355 with ProductID 24 that has name Guaraná Fantástica.
CustomerID AROUT has an OrderID 10355 with ProductID 57 that has name Ravioli Angelo.
CustomerID AROUT has an OrderID 10383 with ProductID 13 that has name Konbu.
CustomerID AROUT has an OrderID 10383 with ProductID 50 that has name Valkoinen suklaa.
CustomerID AROUT has an OrderID 10383 with ProductID 56 that has name Gnocchi di nonna Alice.
CustomerID AROUT has an OrderID 10453 with ProductID 48 that has name Chocolade.
CustomerID AROUT has an OrderID 10453 with ProductID 70 that has name Outback Lager.
CustomerID AROUT has an OrderID 10558 with ProductID 47 that has name Zaanse koeken.
CustomerID AROUT has an OrderID 10558 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID AROUT has an OrderID 10558 with ProductID 52 that has name Filo Mix.
CustomerID AROUT has an OrderID 10558 with ProductID 53 that has name Perth Pasties.
CustomerID AROUT has an OrderID 10558 with ProductID 73 that has name Röd Kaviar.
CustomerID AROUT has an OrderID 10707 with ProductID 55 that has name Pâté chinois.
CustomerID AROUT has an OrderID 10707 with ProductID 57 that has name Ravioli Angelo.
CustomerID AROUT has an OrderID 10707 with ProductID 70 that has name Outback Lager.
CustomerID AROUT has an OrderID 10741 with ProductID 2 that has name Chang.
CustomerID AROUT has an OrderID 10743 with ProductID 46 that has name Spegesild.
CustomerID AROUT has an OrderID 10768 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID AROUT has an OrderID 10768 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 10768 with ProductID 60 that has name Camembert Pierrot.
CustomerID AROUT has an OrderID 10768 with ProductID 71 that has name Flotemysost.
CustomerID AROUT has an OrderID 10793 with ProductID 41 that has name Jack's New England Clam Chowder.
CustomerID AROUT has an OrderID 10793 with ProductID 52 that has name Filo Mix.
CustomerID AROUT has an OrderID 10864 with ProductID 35 that has name Steeleye Stout.
CustomerID AROUT has an OrderID 10864 with ProductID 67 that has name Laughing Lumberjack Lager.
CustomerID AROUT has an OrderID 10920 with ProductID 50 that has name Valkoinen suklaa.
CustomerID AROUT has an OrderID 10953 with ProductID 20 that has name Sir Rodney's Marmalade.
CustomerID AROUT has an OrderID 10953 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 11016 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 11016 with ProductID 36 that has name Inlagd Sill.
CustomerID BSBEV has an OrderID 10289 with ProductID 3 that has name Aniseed Syrup.
CustomerID BSBEV has an OrderID 10289 with ProductID 64 that has name Wimmers gute Semmelknödel.
CustomerID BSBEV has an OrderID 10471 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID BSBEV has an OrderID 10471 with ProductID 56 that has name Gnocchi di nonna Alice.
CustomerID BSBEV has an OrderID 10484 with ProductID 21 that has name Sir Rodney's Scones.
CustomerID BSBEV has an OrderID 10484 with ProductID 40 that has name Boston Crab Meat.
CustomerID BSBEV has an OrderID 10484 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID BSBEV has an OrderID 10538 with ProductID 70 that has name Outback Lager.
CustomerID BSBEV has an OrderID 10538 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID BSBEV has an OrderID 10539 with ProductID 13 that has name Konbu.
CustomerID BSBEV has an OrderID 10539 with ProductID 21 that has name Sir Rodney's Scones.
CustomerID BSBEV has an OrderID 10539 with ProductID 33 that has name Geitost.
CustomerID BSBEV has an OrderID 10539 with ProductID 49 that has name Maxilaku.
CustomerID BSBEV has an OrderID 10578 with ProductID 35 that has name Steeleye Stout.
CustomerID BSBEV has an OrderID 10578 with ProductID 57 that has name Ravioli Angelo.
CustomerID BSBEV has an OrderID 10599 with ProductID 62 that has name Tarte au sucre.
CustomerID BSBEV has an OrderID 10943 with ProductID 13 that has name Konbu.
CustomerID BSBEV has an OrderID 10943 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID BSBEV has an OrderID 10943 with ProductID 46 that has name Spegesild.
CustomerID BSBEV has an OrderID 10947 with ProductID 59 that has name Raclette Courdavault.
CustomerID BSBEV has an OrderID 11023 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID BSBEV has an OrderID 11023 with ProductID 43 that has name Ipoh Coffee.
CustomerID CONSH has an OrderID 10435 with ProductID 2 that has name Chang.
CustomerID CONSH has an OrderID 10435 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID CONSH has an OrderID 10435 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID CONSH has an OrderID 10462 with ProductID 13 that has name Konbu.
CustomerID CONSH has an OrderID 10462 with ProductID 23 that has name Tunnbröd.
CustomerID CONSH has an OrderID 10848 with ProductID 5 that has name Chef Anton's Gumbo Mix.
CustomerID CONSH has an OrderID 10848 with ProductID 9 that has name Mishi Kobe Niku.
CustomerID EASTC has an OrderID 10364 with ProductID 69 that has name Gudbrandsdalsost.
CustomerID EASTC has an OrderID 10364 with ProductID 71 that has name Flotemysost.
CustomerID EASTC has an OrderID 10400 with ProductID 29 that has name Thüringer Rostbratwurst.
CustomerID EASTC has an OrderID 10400 with ProductID 35 that has name Steeleye Stout.
CustomerID EASTC has an OrderID 10400 with ProductID 49 that has name Maxilaku.
CustomerID EASTC has an OrderID 10532 with ProductID 30 that has name Nord-Ost Matjeshering.
CustomerID EASTC has an OrderID 10532 with ProductID 66 that has name Louisiana Hot Spiced Okra.
CustomerID EASTC has an OrderID 10726 with ProductID 4 that has name Chef Anton's Cajun Seasoning.
CustomerID EASTC has an OrderID 10726 with ProductID 11 that has name Queso Cabrales.
CustomerID EASTC has an OrderID 10987 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID EASTC has an OrderID 10987 with ProductID 43 that has name Ipoh Coffee.
CustomerID EASTC has an OrderID 10987 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID EASTC has an OrderID 11024 with ProductID 26 that has name Gumbär Gummibärchen.
CustomerID EASTC has an OrderID 11024 with ProductID 33 that has name Geitost.
CustomerID EASTC has an OrderID 11024 with ProductID 65 that has name Louisiana Fiery Hot Pepper Sauce.
CustomerID EASTC has an OrderID 11024 with ProductID 71 that has name Flotemysost.
CustomerID EASTC has an OrderID 11047 with ProductID 1 that has name Chai.
CustomerID EASTC has an OrderID 11047 with ProductID 5 that has name Chef Anton's Gumbo Mix.
CustomerID EASTC has an OrderID 11056 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID EASTC has an OrderID 11056 with ProductID 55 that has name Pâté chinois.
CustomerID EASTC has an OrderID 11056 with ProductID 60 that has name Camembert Pierrot.
CustomerID NORTS has an OrderID 10517 with ProductID 52 that has name Filo Mix.
CustomerID NORTS has an OrderID 10517 with ProductID 59 that has name Raclette Courdavault.
CustomerID NORTS has an OrderID 10517 with ProductID 70 that has name Outback Lager.
CustomerID NORTS has an OrderID 10752 with ProductID 1 that has name Chai.
CustomerID NORTS has an OrderID 10752 with ProductID 69 that has name Gudbrandsdalsost.
CustomerID NORTS has an OrderID 11057 with ProductID 70 that has name Outback Lager.
CustomerID SEVES has an OrderID 10359 with ProductID 16 that has name Pavlova.
CustomerID SEVES has an OrderID 10359 with ProductID 31 that has name Gorgonzola Telino.
CustomerID SEVES has an OrderID 10359 with ProductID 60 that has name Camembert Pierrot.
CustomerID SEVES has an OrderID 10377 with ProductID 28 that has name Rössle Sauerkraut.
CustomerID SEVES has an OrderID 10377 with ProductID 39 that has name Chartreuse verte.
CustomerID SEVES has an OrderID 10388 with ProductID 45 that has name Rogede sild.
CustomerID SEVES has an OrderID 10388 with ProductID 52 that has name Filo Mix.
CustomerID SEVES has an OrderID 10388 with ProductID 53 that has name Perth Pasties.
CustomerID SEVES has an OrderID 10472 with ProductID 24 that has name Guaraná Fantástica.
CustomerID SEVES has an OrderID 10472 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID SEVES has an OrderID 10523 with ProductID 17 that has name Alice Mutton.
CustomerID SEVES has an OrderID 10523 with ProductID 20 that has name Sir Rodney's Marmalade.
CustomerID SEVES has an OrderID 10523 with ProductID 37 that has name Gravad lax.
CustomerID SEVES has an OrderID 10523 with ProductID 41 that has name Jack's New England Clam Chowder.
CustomerID SEVES has an OrderID 10547 with ProductID 32 that has name Mascarpone Fabioli.
CustomerID SEVES has an OrderID 10547 with ProductID 36 that has name Inlagd Sill.
CustomerID SEVES has an OrderID 10800 with ProductID 11 that has name Queso Cabrales.
CustomerID SEVES has an OrderID 10800 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID SEVES has an OrderID 10800 with ProductID 54 that has name Tourtière.
CustomerID SEVES has an OrderID 10804 with ProductID 10 that has name Ikura.
CustomerID SEVES has an OrderID 10804 with ProductID 28 that has name Rössle Sauerkraut.
CustomerID SEVES has an OrderID 10804 with ProductID 49 that has name Maxilaku.
CustomerID SEVES has an OrderID 10869 with ProductID 1 that has name Chai.
CustomerID SEVES has an OrderID 10869 with ProductID 11 that has name Queso Cabrales.
CustomerID SEVES has an OrderID 10869 with ProductID 23 that has name Tunnbröd.
CustomerID SEVES has an OrderID 10869 with ProductID 68 that has name Scottish Longbreads.
This sample demonstrates how to use Including to request related data during the original query so that additional roundtrips to the database are not required later when navigating through the retrieved objects.
Public Sub LinqToSqlObject04()
Dim db2 = New NorthwindDataContext(My.Settings.NORTHWINDConnectionString1)
Dim ds = New DataLoadOptions()
ds.LoadWith(Of Customer)(Function(p) p.Orders)
ds.LoadWith(Of Order)(Function(p) p.Order_Details)
db2.LoadOptions = ds
Dim custs = From c In db.Customers _
Where c.City = "London" _
Select c
For Each cust In custs
For Each ord In cust.Orders
For Each orderDetail In ord.Order_Details
Console.WriteLine("CustomerID {0} has an OrderID {1} with ProductID {2} that has name {3}.", _
cust.CustomerID, ord.OrderID, orderDetail.ProductID, orderDetail.Product.ProductName)
Next
Next
Next
End Sub
Result:
CustomerID AROUT has an OrderID 10355 with ProductID 24 that has name Guaraná Fantástica.
CustomerID AROUT has an OrderID 10355 with ProductID 57 that has name Ravioli Angelo.
CustomerID AROUT has an OrderID 10383 with ProductID 13 that has name Konbu.
CustomerID AROUT has an OrderID 10383 with ProductID 50 that has name Valkoinen suklaa.
CustomerID AROUT has an OrderID 10383 with ProductID 56 that has name Gnocchi di nonna Alice.
CustomerID AROUT has an OrderID 10453 with ProductID 48 that has name Chocolade.
CustomerID AROUT has an OrderID 10453 with ProductID 70 that has name Outback Lager.
CustomerID AROUT has an OrderID 10558 with ProductID 47 that has name Zaanse koeken.
CustomerID AROUT has an OrderID 10558 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID AROUT has an OrderID 10558 with ProductID 52 that has name Filo Mix.
CustomerID AROUT has an OrderID 10558 with ProductID 53 that has name Perth Pasties.
CustomerID AROUT has an OrderID 10558 with ProductID 73 that has name Röd Kaviar.
CustomerID AROUT has an OrderID 10707 with ProductID 55 that has name Pâté chinois.
CustomerID AROUT has an OrderID 10707 with ProductID 57 that has name Ravioli Angelo.
CustomerID AROUT has an OrderID 10707 with ProductID 70 that has name Outback Lager.
CustomerID AROUT has an OrderID 10741 with ProductID 2 that has name Chang.
CustomerID AROUT has an OrderID 10743 with ProductID 46 that has name Spegesild.
CustomerID AROUT has an OrderID 10768 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID AROUT has an OrderID 10768 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 10768 with ProductID 60 that has name Camembert Pierrot.
CustomerID AROUT has an OrderID 10768 with ProductID 71 that has name Flotemysost.
CustomerID AROUT has an OrderID 10793 with ProductID 41 that has name Jack's New England Clam Chowder.
CustomerID AROUT has an OrderID 10793 with ProductID 52 that has name Filo Mix.
CustomerID AROUT has an OrderID 10864 with ProductID 35 that has name Steeleye Stout.
CustomerID AROUT has an OrderID 10864 with ProductID 67 that has name Laughing Lumberjack Lager.
CustomerID AROUT has an OrderID 10920 with ProductID 50 that has name Valkoinen suklaa.
CustomerID AROUT has an OrderID 10953 with ProductID 20 that has name Sir Rodney's Marmalade.
CustomerID AROUT has an OrderID 10953 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 11016 with ProductID 31 that has name Gorgonzola Telino.
CustomerID AROUT has an OrderID 11016 with ProductID 36 that has name Inlagd Sill.
CustomerID BSBEV has an OrderID 10289 with ProductID 3 that has name Aniseed Syrup.
CustomerID BSBEV has an OrderID 10289 with ProductID 64 that has name Wimmers gute Semmelknödel.
CustomerID BSBEV has an OrderID 10471 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID BSBEV has an OrderID 10471 with ProductID 56 that has name Gnocchi di nonna Alice.
CustomerID BSBEV has an OrderID 10484 with ProductID 21 that has name Sir Rodney's Scones.
CustomerID BSBEV has an OrderID 10484 with ProductID 40 that has name Boston Crab Meat.
CustomerID BSBEV has an OrderID 10484 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID BSBEV has an OrderID 10538 with ProductID 70 that has name Outback Lager.
CustomerID BSBEV has an OrderID 10538 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID BSBEV has an OrderID 10539 with ProductID 13 that has name Konbu.
CustomerID BSBEV has an OrderID 10539 with ProductID 21 that has name Sir Rodney's Scones.
CustomerID BSBEV has an OrderID 10539 with ProductID 33 that has name Geitost.
CustomerID BSBEV has an OrderID 10539 with ProductID 49 that has name Maxilaku.
CustomerID BSBEV has an OrderID 10578 with ProductID 35 that has name Steeleye Stout.
CustomerID BSBEV has an OrderID 10578 with ProductID 57 that has name Ravioli Angelo.
CustomerID BSBEV has an OrderID 10599 with ProductID 62 that has name Tarte au sucre.
CustomerID BSBEV has an OrderID 10943 with ProductID 13 that has name Konbu.
CustomerID BSBEV has an OrderID 10943 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID BSBEV has an OrderID 10943 with ProductID 46 that has name Spegesild.
CustomerID BSBEV has an OrderID 10947 with ProductID 59 that has name Raclette Courdavault.
CustomerID BSBEV has an OrderID 11023 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID BSBEV has an OrderID 11023 with ProductID 43 that has name Ipoh Coffee.
CustomerID CONSH has an OrderID 10435 with ProductID 2 that has name Chang.
CustomerID CONSH has an OrderID 10435 with ProductID 22 that has name Gustaf's Knäckebröd.
CustomerID CONSH has an OrderID 10435 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID CONSH has an OrderID 10462 with ProductID 13 that has name Konbu.
CustomerID CONSH has an OrderID 10462 with ProductID 23 that has name Tunnbröd.
CustomerID CONSH has an OrderID 10848 with ProductID 5 that has name Chef Anton's Gumbo Mix.
CustomerID CONSH has an OrderID 10848 with ProductID 9 that has name Mishi Kobe Niku.
CustomerID EASTC has an OrderID 10364 with ProductID 69 that has name Gudbrandsdalsost.
CustomerID EASTC has an OrderID 10364 with ProductID 71 that has name Flotemysost.
CustomerID EASTC has an OrderID 10400 with ProductID 29 that has name Thüringer Rostbratwurst.
CustomerID EASTC has an OrderID 10400 with ProductID 35 that has name Steeleye Stout.
CustomerID EASTC has an OrderID 10400 with ProductID 49 that has name Maxilaku.
CustomerID EASTC has an OrderID 10532 with ProductID 30 that has name Nord-Ost Matjeshering.
CustomerID EASTC has an OrderID 10532 with ProductID 66 that has name Louisiana Hot Spiced Okra.
CustomerID EASTC has an OrderID 10726 with ProductID 4 that has name Chef Anton's Cajun Seasoning.
CustomerID EASTC has an OrderID 10726 with ProductID 11 that has name Queso Cabrales.
CustomerID EASTC has an OrderID 10987 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID EASTC has an OrderID 10987 with ProductID 43 that has name Ipoh Coffee.
CustomerID EASTC has an OrderID 10987 with ProductID 72 that has name Mozzarella di Giovanni.
CustomerID EASTC has an OrderID 11024 with ProductID 26 that has name Gumbär Gummibärchen.
CustomerID EASTC has an OrderID 11024 with ProductID 33 that has name Geitost.
CustomerID EASTC has an OrderID 11024 with ProductID 65 that has name Louisiana Fiery Hot Pepper Sauce.
CustomerID EASTC has an OrderID 11024 with ProductID 71 that has name Flotemysost.
CustomerID EASTC has an OrderID 11047 with ProductID 1 that has name Chai.
CustomerID EASTC has an OrderID 11047 with ProductID 5 that has name Chef Anton's Gumbo Mix.
CustomerID EASTC has an OrderID 11056 with ProductID 7 that has name Uncle Bob's Organic Dried Pears.
CustomerID EASTC has an OrderID 11056 with ProductID 55 that has name Pâté chinois.
CustomerID EASTC has an OrderID 11056 with ProductID 60 that has name Camembert Pierrot.
CustomerID NORTS has an OrderID 10517 with ProductID 52 that has name Filo Mix.
CustomerID NORTS has an OrderID 10517 with ProductID 59 that has name Raclette Courdavault.
CustomerID NORTS has an OrderID 10517 with ProductID 70 that has name Outback Lager.
CustomerID NORTS has an OrderID 10752 with ProductID 1 that has name Chai.
CustomerID NORTS has an OrderID 10752 with ProductID 69 that has name Gudbrandsdalsost.
CustomerID NORTS has an OrderID 11057 with ProductID 70 that has name Outback Lager.
CustomerID SEVES has an OrderID 10359 with ProductID 16 that has name Pavlova.
CustomerID SEVES has an OrderID 10359 with ProductID 31 that has name Gorgonzola Telino.
CustomerID SEVES has an OrderID 10359 with ProductID 60 that has name Camembert Pierrot.
CustomerID SEVES has an OrderID 10377 with ProductID 28 that has name Rössle Sauerkraut.
CustomerID SEVES has an OrderID 10377 with ProductID 39 that has name Chartreuse verte.
CustomerID SEVES has an OrderID 10388 with ProductID 45 that has name Rogede sild.
CustomerID SEVES has an OrderID 10388 with ProductID 52 that has name Filo Mix.
CustomerID SEVES has an OrderID 10388 with ProductID 53 that has name Perth Pasties.
CustomerID SEVES has an OrderID 10472 with ProductID 24 that has name Guaraná Fantástica.
CustomerID SEVES has an OrderID 10472 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID SEVES has an OrderID 10523 with ProductID 17 that has name Alice Mutton.
CustomerID SEVES has an OrderID 10523 with ProductID 20 that has name Sir Rodney's Marmalade.
CustomerID SEVES has an OrderID 10523 with ProductID 37 that has name Gravad lax.
CustomerID SEVES has an OrderID 10523 with ProductID 41 that has name Jack's New England Clam Chowder.
CustomerID SEVES has an OrderID 10547 with ProductID 32 that has name Mascarpone Fabioli.
CustomerID SEVES has an OrderID 10547 with ProductID 36 that has name Inlagd Sill.
CustomerID SEVES has an OrderID 10800 with ProductID 11 that has name Queso Cabrales.
CustomerID SEVES has an OrderID 10800 with ProductID 51 that has name Manjimup Dried Apples.
CustomerID SEVES has an OrderID 10800 with ProductID 54 that has name Tourtière.
CustomerID SEVES has an OrderID 10804 with ProductID 10 that has name Ikura.
CustomerID SEVES has an OrderID 10804 with ProductID 28 that has name Rössle Sauerkraut.
CustomerID SEVES has an OrderID 10804 with ProductID 49 that has name Maxilaku.
CustomerID SEVES has an OrderID 10869 with ProductID 1 that has name Chai.
CustomerID SEVES has an OrderID 10869 with ProductID 11 that has name Queso Cabrales.
CustomerID SEVES has an OrderID 10869 with ProductID 23 that has name Tunnbröd.
CustomerID SEVES has an OrderID 10869 with ProductID 68 that has name Scottish Longbreads.
This sample demonstrates how navigating through relationships in retrieved objects can result in triggering new queries to the database if the data was not requested by the original query.
Public Sub LinqToSqlObject05()
Dim emps = From e In db.Employees
For Each emp In emps
For Each man In emp.Employees
Console.WriteLine("Employee {0} reported to Manager {1}.", emp.FirstName, man.FirstName)
Next
Next
End Sub
Result:
Employee Andrew reported to Manager Nancy.
Employee Andrew reported to Manager Janet.
Employee Andrew reported to Manager Margaret.
Employee Andrew reported to Manager Steven.
Employee Andrew reported to Manager Laura.
Employee Steven reported to Manager Michael.
Employee Steven reported to Manager Robert.
Employee Steven reported to Manager Anne.
This sample demonstrates how navigating through Link in retrieved objects can end up triggering new queries to the database if the data type is Link.
Public Sub LinqToSqlObject06()
Dim emps = From c In db.Employees
For Each emp In emps
Console.WriteLine("{0}", emp.Notes)
Next
End Sub
Result:
Education includes a BA in psychology from Colorado State University in 1970. She also completed "The Art of the Cold Call." Nancy is a member of Toastmasters International.
Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.
Janet has a BS degree in chemistry from Boston College (1984). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.
Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966). She was assigned to the London office temporarily from July through November 1992.
Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976. Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 1993. Mr. Buchanan has completed the courses "Successful Telemarketing" and "International Sales Management." He is fluent in French.
Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986). He has also taken the courses "Multi-Cultural Selling" and "Time Management for the Sales Professional." He is fluent in Japanese and can read and write French, Portuguese, and Spanish.
Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company. After completing a course entitled "Selling in Europe," he was transferred to the London office in March 1993.
Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.
Anne has a BA degree in English from St. Lawrence College. She is fluent in French and German.