Skip to main content

Where - 1

This sample uses where to filter for Customers in London.

Public Sub LinqToSqlWhere01()
    Dim q = From c In db.Customers _
        Where c.City = "London"

    ObjectDumper.Write(q)
End Sub

Result:
CustomerID=AROUT        CompanyName=Around the Horn     ContactName=Thomas Hardy        ContactTitle=Sales Representative       Address=120 Hanover Sq.         City=London     Region=null     PostalCode=WA1 1DP      Country=UK      Phone=(171) 555-7788    Fax=(171) 555-6750      Orders=...      CustomerCustomerDemos=...
CustomerID=BSBEV        CompanyName=B's Beverages       ContactName=Victoria Ashworth   ContactTitle=Sales Representative       Address=Fauntleroy Circus       City=London     Region=null     PostalCode=EC2 5NT      Country=UK      Phone=(171) 555-1212    Fax=null        Orders=...      CustomerCustomerDemos=...
CustomerID=CONSH        CompanyName=Consolidated Holdings       ContactName=Elizabeth Brown     ContactTitle=Sales Representative       Address=Berkeley Gardens 12  Brewery    City=London     Region=null     PostalCode=WX1 6LT      Country=UK      Phone=(171) 555-2282    Fax=(171) 555-9199      Orders=...      CustomerCustomerDemos=...
CustomerID=EASTC        CompanyName=Eastern Connection  ContactName=Ann Devon   ContactTitle=Sales Agent        Address=35 King George  City=London     Region=null     PostalCode=WX3 6FW      Country=UK      Phone=(171) 555-0297    Fax=(171) 555-3373      Orders=...      CustomerCustomerDemos=...
CustomerID=NORTS        CompanyName=North/South         ContactName=Simon Crowther      ContactTitle=Sales Associate    Address=South House 300 Queensbridge    City=London     Region=null     PostalCode=SW7 1RZ      Country=UK      Phone=(171) 555-7733    Fax=(171) 555-2530      Orders=...      CustomerCustomerDemos=...
CustomerID=SEVES        CompanyName=Seven Seas Imports  ContactName=Hari Kumar  ContactTitle=Sales Manager      Address=90 Wadhurst Rd.         City=London     Region=null     PostalCode=OX15 4NB     Country=UK      Phone=(171) 555-1717    Fax=(171) 555-5646      Orders=...      CustomerCustomerDemos=...


Where - 2

This sample uses where to filter for Employees hired during or after 1994.

Public Sub LinqToSqlWhere02()
    Dim q = From e In db.Employees _
        Where e.HireDate >= #1/1/1994# _
        Select e

    ObjectDumper.Write(q)
End Sub

Result:
EmployeeID=7    LastName=King   FirstName=Robert        Title=Sales Representative      TitleOfCourtesy=Mr.     BirthDate=5/29/1960     HireDate=1/2/1994       Address=Edgeham Hollow
Winchester Way  City=London     Region=null     PostalCode=RG1 9SP      Country=UK      HomePhone=(71) 555-5598         Extension=465   Photo=...       Notes=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.     ReportsTo=5     PhotoPath=http://accweb/emmployees/davolio.bmp  Orders=...      EmployeeTerritories=...         Employees=...   Employee={ }
EmployeeID=8    LastName=Callahan       FirstName=Laura         Title=Inside Sales Coordinator  TitleOfCourtesy=Ms.     BirthDate=1/9/1958      HireDate=3/5/1994       Address=4726 - 11th Ave. N.E.   City=Seattle    Region=WA       PostalCode=98105        Country=USA     HomePhone=(206) 555-1189        Extension=2344  Photo=...       Notes=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.   ReportsTo=2     PhotoPath=http://accweb/emmployees/davolio.bmp  Orders=...      EmployeeTerritories=...         Employees=...   Employee={ }
EmployeeID=9    LastName=Dodsworth      FirstName=Anne  Title=Sales Representative      TitleOfCourtesy=Ms.     BirthDate=1/27/1966     HireDate=11/15/1994     Address=7 Houndstooth Rd.       City=London     Region=null     PostalCode=WG2 7LT      Country=UK      HomePhone=(71) 555-4444         Extension=452   Photo=...       Notes=Anne has a BA degree in English from St. Lawrence College.  She is fluent in French and German.   ReportsTo=5     PhotoPath=http://accweb/emmployees/davolio.bmp  Orders=...      EmployeeTerritories=...         Employees=...   Employee={ }


Where - 3

This sample uses where to filter for Products that have stock below their reorder level and are not discontinued.

Public Sub LinqToSqlWhere03()
    Dim q = From p In db.Products _
        Where p.UnitsInStock <= p.ReorderLevel AndAlso Not p.Discontinued _
        Select p

    ObjectDumper.Write(q)
End Sub

Result:
ProductID=2     ProductName=Chang       SupplierID=1    CategoryID=1    QuantityPerUnit=24 - 12 oz bottles      UnitPrice=19.0000       UnitsInStock=17         UnitsOnOrder=40         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=3     ProductName=Aniseed Syrup       SupplierID=1    CategoryID=2    QuantityPerUnit=12 - 550 ml bottles     UnitPrice=10.0000       UnitsInStock=13         UnitsOnOrder=70         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=11    ProductName=Queso Cabrales      SupplierID=5    CategoryID=4    QuantityPerUnit=1 kg pkg.       UnitPrice=22.0000       UnitsInStock=22         UnitsOnOrder=30         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=21    ProductName=Sir Rodney's Scones         SupplierID=8    CategoryID=3    QuantityPerUnit=24 pkgs. x 4 pieces     UnitPrice=11.0000       UnitsInStock=3  UnitsOnOrder=40         ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=30    ProductName=Nord-Ost Matjeshering       SupplierID=13   CategoryID=8    QuantityPerUnit=10 - 200 g glasses      UnitPrice=26.8900       UnitsInStock=10         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=31    ProductName=Gorgonzola Telino   SupplierID=14   CategoryID=4    QuantityPerUnit=12 - 100 g pkgs         UnitPrice=13.5000       UnitsInStock=0  UnitsOnOrder=70         ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=32    ProductName=Mascarpone Fabioli  SupplierID=14   CategoryID=4    QuantityPerUnit=24 - 200 g pkgs.        UnitPrice=33.0000       UnitsInStock=9  UnitsOnOrder=40         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=37    ProductName=Gravad lax  SupplierID=17   CategoryID=8    QuantityPerUnit=12 - 500 g pkgs.        UnitPrice=27.0000       UnitsInStock=11         UnitsOnOrder=50         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=43    ProductName=Ipoh Coffee         SupplierID=20   CategoryID=1    QuantityPerUnit=16 - 500 g tins         UnitPrice=47.0000       UnitsInStock=17         UnitsOnOrder=10         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=45    ProductName=Rogede sild         SupplierID=21   CategoryID=8    QuantityPerUnit=1k pkg.         UnitPrice=10.5000       UnitsInStock=5  UnitsOnOrder=70         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=48    ProductName=Chocolade   SupplierID=22   CategoryID=3    QuantityPerUnit=10 pkgs.        UnitPrice=13.7500       UnitsInStock=15         UnitsOnOrder=70         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=49    ProductName=Maxilaku    SupplierID=23   CategoryID=3    QuantityPerUnit=24 - 50 g pkgs.         UnitPrice=21.0000       UnitsInStock=10         UnitsOnOrder=60         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=56    ProductName=Gnocchi di nonna Alice      SupplierID=26   CategoryID=5    QuantityPerUnit=24 - 250 g pkgs.        UnitPrice=39.0000       UnitsInStock=21         UnitsOnOrder=10         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=64    ProductName=Wimmers gute Semmelknödel   SupplierID=12   CategoryID=5    QuantityPerUnit=20 bags x 4 pieces      UnitPrice=34.2500       UnitsInStock=22         UnitsOnOrder=80         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=66    ProductName=Louisiana Hot Spiced Okra   SupplierID=2    CategoryID=2    QuantityPerUnit=24 - 8 oz jars  UnitPrice=18.0000       UnitsInStock=4  UnitsOnOrder=100        ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=68    ProductName=Scottish Longbreads         SupplierID=8    CategoryID=3    QuantityPerUnit=10 boxes x 8 pieces     UnitPrice=13.5000       UnitsInStock=6  UnitsOnOrder=10         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=70    ProductName=Outback Lager       SupplierID=7    CategoryID=1    QuantityPerUnit=24 - 355 ml bottles     UnitPrice=16.0000       UnitsInStock=15         UnitsOnOrder=10         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=74    ProductName=Longlife Tofu       SupplierID=4    CategoryID=7    QuantityPerUnit=5 kg pkg.       UnitPrice=11.0000       UnitsInStock=4  UnitsOnOrder=20         ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }


Where - 4

This sample uses WHERE to filter out Products that are either UnitPrice is greater than 10 or is discontinued.

Public Sub LinqToSqlWhere04()
    Dim q = From p In db.Products _
            Where p.UnitPrice > 10.0# OrElse p.Discontinued

    ObjectDumper.Write(q, 0)
End Sub

Result:
ProductID=1     ProductName=Chai        SupplierID=1    CategoryID=1    QuantityPerUnit=10 boxes x 20 bags      UnitPrice=18.0000       UnitsInStock=39         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=2     ProductName=Chang       SupplierID=1    CategoryID=1    QuantityPerUnit=24 - 12 oz bottles      UnitPrice=19.0000       UnitsInStock=17         UnitsOnOrder=40         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=4     ProductName=Chef Anton's Cajun Seasoning        SupplierID=2    CategoryID=2    QuantityPerUnit=48 - 6 oz jars  UnitPrice=22.0000       UnitsInStock=53         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=5     ProductName=Chef Anton's Gumbo Mix      SupplierID=2    CategoryID=2    QuantityPerUnit=36 boxes        UnitPrice=22.3500       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=6     ProductName=Grandma's Boysenberry Spread        SupplierID=3    CategoryID=2    QuantityPerUnit=12 - 8 oz jars  UnitPrice=26.0000       UnitsInStock=120        UnitsOnOrder=0  ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=7     ProductName=Uncle Bob's Organic Dried Pears     SupplierID=3    CategoryID=7    QuantityPerUnit=12 - 1 lb pkgs.         UnitPrice=31.0000       UnitsInStock=15         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=8     ProductName=Northwoods Cranberry Sauce  SupplierID=3    CategoryID=2    QuantityPerUnit=12 - 12 oz jars         UnitPrice=41.0000       UnitsInStock=6  UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=9     ProductName=Mishi Kobe Niku     SupplierID=4    CategoryID=6    QuantityPerUnit=18 - 500 g pkgs.        UnitPrice=98.0000       UnitsInStock=29         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=10    ProductName=Ikura       SupplierID=4    CategoryID=8    QuantityPerUnit=12 - 200 ml jars        UnitPrice=32.0000       UnitsInStock=31         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=11    ProductName=Queso Cabrales      SupplierID=5    CategoryID=4    QuantityPerUnit=1 kg pkg.       UnitPrice=22.0000       UnitsInStock=22         UnitsOnOrder=30         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=12    ProductName=Queso Manchego La Pastora   SupplierID=5    CategoryID=4    QuantityPerUnit=10 - 500 g pkgs.        UnitPrice=39.0000       UnitsInStock=86         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=14    ProductName=Tofu        SupplierID=6    CategoryID=7    QuantityPerUnit=40 - 100 g pkgs.        UnitPrice=24.2500       UnitsInStock=35         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=15    ProductName=Genen Shouyu        SupplierID=6    CategoryID=2    QuantityPerUnit=24 - 250 ml bottles     UnitPrice=16.5000       UnitsInStock=39         UnitsOnOrder=0  ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=16    ProductName=Pavlova     SupplierID=7    CategoryID=3    QuantityPerUnit=32 - 500 g boxes        UnitPrice=18.4500       UnitsInStock=29         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=17    ProductName=Alice Mutton        SupplierID=7    CategoryID=6    QuantityPerUnit=20 - 1 kg tins  UnitPrice=40.0000       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=18    ProductName=Carnarvon Tigers    SupplierID=7    CategoryID=8    QuantityPerUnit=16 kg pkg.      UnitPrice=63.5000       UnitsInStock=42         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=19    ProductName=Teatime Chocolate Biscuits  SupplierID=8    CategoryID=3    QuantityPerUnit=10 boxes x 12 pieces    UnitPrice=10.2000       UnitsInStock=25         UnitsOnOrder=0  ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=20    ProductName=Sir Rodney's Marmalade      SupplierID=8    CategoryID=3    QuantityPerUnit=30 gift boxes   UnitPrice=82.0000       UnitsInStock=40         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=21    ProductName=Sir Rodney's Scones         SupplierID=8    CategoryID=3    QuantityPerUnit=24 pkgs. x 4 pieces     UnitPrice=11.0000       UnitsInStock=3  UnitsOnOrder=40         ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=22    ProductName=Gustaf's Knäckebröd         SupplierID=9    CategoryID=5    QuantityPerUnit=24 - 500 g pkgs.        UnitPrice=22.0000       UnitsInStock=104        UnitsOnOrder=0  ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=24    ProductName=Guaraná Fantástica  SupplierID=10   CategoryID=1    QuantityPerUnit=12 - 355 ml cans        UnitPrice=5.5000        UnitsInStock=20         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=25    ProductName=NuNuCa Nuß-Nougat-Creme     SupplierID=11   CategoryID=3    QuantityPerUnit=20 - 450 g glasses      UnitPrice=15.0000       UnitsInStock=76         UnitsOnOrder=0  ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=26    ProductName=Gumbär Gummibärchen         SupplierID=11   CategoryID=3    QuantityPerUnit=100 - 250 g bags        UnitPrice=32.2300       UnitsInStock=15         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=27    ProductName=Schoggi Schokolade  SupplierID=11   CategoryID=3    QuantityPerUnit=100 - 100 g pieces      UnitPrice=44.9000       UnitsInStock=49         UnitsOnOrder=0  ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=28    ProductName=Rössle Sauerkraut   SupplierID=12   CategoryID=7    QuantityPerUnit=25 - 825 g cans         UnitPrice=46.6000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=29    ProductName=Thüringer Rostbratwurst     SupplierID=12   CategoryID=6    QuantityPerUnit=50 bags x 30 sausgs.    UnitPrice=124.7900      UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=30    ProductName=Nord-Ost Matjeshering       SupplierID=13   CategoryID=8    QuantityPerUnit=10 - 200 g glasses      UnitPrice=26.8900       UnitsInStock=10         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=31    ProductName=Gorgonzola Telino   SupplierID=14   CategoryID=4    QuantityPerUnit=12 - 100 g pkgs         UnitPrice=13.5000       UnitsInStock=0  UnitsOnOrder=70         ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=32    ProductName=Mascarpone Fabioli  SupplierID=14   CategoryID=4    QuantityPerUnit=24 - 200 g pkgs.        UnitPrice=33.0000       UnitsInStock=9  UnitsOnOrder=40         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=34    ProductName=Sasquatch Ale       SupplierID=16   CategoryID=1    QuantityPerUnit=24 - 12 oz bottles      UnitPrice=15.0000       UnitsInStock=111        UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=35    ProductName=Steeleye Stout      SupplierID=16   CategoryID=1    QuantityPerUnit=24 - 12 oz bottles      UnitPrice=19.0000       UnitsInStock=20         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=36    ProductName=Inlagd Sill         SupplierID=17   CategoryID=8    QuantityPerUnit=24 - 250 g  jars        UnitPrice=20.0000       UnitsInStock=112        UnitsOnOrder=0  ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=37    ProductName=Gravad lax  SupplierID=17   CategoryID=8    QuantityPerUnit=12 - 500 g pkgs.        UnitPrice=27.0000       UnitsInStock=11         UnitsOnOrder=50         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=38    ProductName=Côte de Blaye       SupplierID=18   CategoryID=1    QuantityPerUnit=12 - 75 cl bottles      UnitPrice=264.5000      UnitsInStock=17         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=39    ProductName=Chartreuse verte    SupplierID=18   CategoryID=1    QuantityPerUnit=750 cc per bottle       UnitPrice=19.0000       UnitsInStock=69         UnitsOnOrder=0  ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=40    ProductName=Boston Crab Meat    SupplierID=19   CategoryID=8    QuantityPerUnit=24 - 4 oz tins  UnitPrice=19.4000       UnitsInStock=123        UnitsOnOrder=0  ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=41    ProductName=Jack's New England Clam Chowder     SupplierID=19   CategoryID=8    QuantityPerUnit=12 - 12 oz cans         UnitPrice=10.6500       UnitsInStock=85         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=42    ProductName=Singaporean Hokkien Fried Mee       SupplierID=20   CategoryID=5    QuantityPerUnit=32 - 1 kg pkgs.         UnitPrice=15.0000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=43    ProductName=Ipoh Coffee         SupplierID=20   CategoryID=1    QuantityPerUnit=16 - 500 g tins         UnitPrice=47.0000       UnitsInStock=17         UnitsOnOrder=10         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=44    ProductName=Gula Malacca        SupplierID=20   CategoryID=2    QuantityPerUnit=20 - 2 kg bags  UnitPrice=20.4500       UnitsInStock=27         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=45    ProductName=Rogede sild         SupplierID=21   CategoryID=8    QuantityPerUnit=1k pkg.         UnitPrice=10.5000       UnitsInStock=5  UnitsOnOrder=70         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=46    ProductName=Spegesild   SupplierID=21   CategoryID=8    QuantityPerUnit=4 - 450 g glasses       UnitPrice=13.0000       UnitsInStock=95         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=47    ProductName=Zaanse koeken       SupplierID=22   CategoryID=3    QuantityPerUnit=10 - 4 oz boxes         UnitPrice=10.5000       UnitsInStock=36         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=48    ProductName=Chocolade   SupplierID=22   CategoryID=3    QuantityPerUnit=10 pkgs.        UnitPrice=13.7500       UnitsInStock=15         UnitsOnOrder=70         ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=49    ProductName=Maxilaku    SupplierID=23   CategoryID=3    QuantityPerUnit=24 - 50 g pkgs.         UnitPrice=21.0000       UnitsInStock=10         UnitsOnOrder=60         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=50    ProductName=Valkoinen suklaa    SupplierID=23   CategoryID=3    QuantityPerUnit=12 - 100 g bars         UnitPrice=17.2500       UnitsInStock=65         UnitsOnOrder=0  ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=51    ProductName=Manjimup Dried Apples       SupplierID=24   CategoryID=7    QuantityPerUnit=50 - 300 g pkgs.        UnitPrice=54.0000       UnitsInStock=20         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=53    ProductName=Perth Pasties       SupplierID=24   CategoryID=6    QuantityPerUnit=48 pieces       UnitPrice=33.8000       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=55    ProductName=Pâté chinois        SupplierID=25   CategoryID=6    QuantityPerUnit=24 boxes x 2 pies       UnitPrice=25.0000       UnitsInStock=115        UnitsOnOrder=0  ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=56    ProductName=Gnocchi di nonna Alice      SupplierID=26   CategoryID=5    QuantityPerUnit=24 - 250 g pkgs.        UnitPrice=39.0000       UnitsInStock=21         UnitsOnOrder=10         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=57    ProductName=Ravioli Angelo      SupplierID=26   CategoryID=5    QuantityPerUnit=24 - 250 g pkgs.        UnitPrice=20.5000       UnitsInStock=36         UnitsOnOrder=0  ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=58    ProductName=Escargots de Bourgogne      SupplierID=27   CategoryID=8    QuantityPerUnit=24 pieces       UnitPrice=14.2500       UnitsInStock=62         UnitsOnOrder=0  ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=59    ProductName=Raclette Courdavault        SupplierID=28   CategoryID=4    QuantityPerUnit=5 kg pkg.       UnitPrice=56.0000       UnitsInStock=79         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=60    ProductName=Camembert Pierrot   SupplierID=28   CategoryID=4    QuantityPerUnit=15 - 300 g rounds       UnitPrice=35.0000       UnitsInStock=19         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=61    ProductName=Sirop d'érable      SupplierID=29   CategoryID=2    QuantityPerUnit=24 - 500 ml bottles     UnitPrice=29.5000       UnitsInStock=113        UnitsOnOrder=0  ReorderLevel=25         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=62    ProductName=Tarte au sucre      SupplierID=29   CategoryID=3    QuantityPerUnit=48 pies         UnitPrice=50.3000       UnitsInStock=17         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=63    ProductName=Vegie-spread        SupplierID=7    CategoryID=2    QuantityPerUnit=15 - 625 g jars         UnitPrice=44.9000       UnitsInStock=24         UnitsOnOrder=0  ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=64    ProductName=Wimmers gute Semmelknödel   SupplierID=12   CategoryID=5    QuantityPerUnit=20 bags x 4 pieces      UnitPrice=34.2500       UnitsInStock=22         UnitsOnOrder=80         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=65    ProductName=Louisiana Fiery Hot Pepper Sauce    SupplierID=2    CategoryID=2    QuantityPerUnit=32 - 8 oz bottles       UnitPrice=22.0500       UnitsInStock=76         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=66    ProductName=Louisiana Hot Spiced Okra   SupplierID=2    CategoryID=2    QuantityPerUnit=24 - 8 oz jars  UnitPrice=18.0000       UnitsInStock=4  UnitsOnOrder=100        ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=67    ProductName=Laughing Lumberjack Lager   SupplierID=16   CategoryID=1    QuantityPerUnit=24 - 12 oz bottles      UnitPrice=15.0000       UnitsInStock=52         UnitsOnOrder=0  ReorderLevel=10         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=68    ProductName=Scottish Longbreads         SupplierID=8    CategoryID=3    QuantityPerUnit=10 boxes x 8 pieces     UnitPrice=13.5000       UnitsInStock=6  UnitsOnOrder=10         ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=69    ProductName=Gudbrandsdalsost    SupplierID=15   CategoryID=4    QuantityPerUnit=10 kg pkg.      UnitPrice=37.0000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=70    ProductName=Outback Lager       SupplierID=7    CategoryID=1    QuantityPerUnit=24 - 355 ml bottles     UnitPrice=16.0000       UnitsInStock=15         UnitsOnOrder=10         ReorderLevel=30         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=71    ProductName=Flotemysost         SupplierID=15   CategoryID=4    QuantityPerUnit=10 - 500 g pkgs.        UnitPrice=22.5000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=72    ProductName=Mozzarella di Giovanni      SupplierID=14   CategoryID=4    QuantityPerUnit=24 - 200 g pkgs.        UnitPrice=35.8000       UnitsInStock=14         UnitsOnOrder=0  ReorderLevel=0  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=73    ProductName=Röd Kaviar  SupplierID=17   CategoryID=8    QuantityPerUnit=24 - 150 g jars         UnitPrice=16.0000       UnitsInStock=101        UnitsOnOrder=0  ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=74    ProductName=Longlife Tofu       SupplierID=4    CategoryID=7    QuantityPerUnit=5 kg pkg.       UnitPrice=11.0000       UnitsInStock=4  UnitsOnOrder=20         ReorderLevel=5  Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=76    ProductName=Lakkalikööri        SupplierID=23   CategoryID=1    QuantityPerUnit=500 ml  UnitPrice=19.0000       UnitsInStock=57         UnitsOnOrder=0  ReorderLevel=20         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }
ProductID=77    ProductName=Original Frankfurter grüne Soße     SupplierID=12   CategoryID=2    QuantityPerUnit=12 boxes        UnitPrice=14.0000       UnitsInStock=32         UnitsOnOrder=0  ReorderLevel=15         Discontinued=False      Order_Details=...       Category={ }    Supplier={ }


Where - 5

This sample calls WHERE twice to filter out Products that UnitPrice is greater than 10 and is discontinued.

Public Sub LinqToSqlWhere05()
    Dim q = db.Products.Where( _
                              Function(p) p.UnitPrice > 10.0#).Where( _
                              Function(p) p.Discontinued)

    ObjectDumper.Write(q, 0)
End Sub

Result:
ProductID=5     ProductName=Chef Anton's Gumbo Mix      SupplierID=2    CategoryID=2    QuantityPerUnit=36 boxes        UnitPrice=22.3500       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=9     ProductName=Mishi Kobe Niku     SupplierID=4    CategoryID=6    QuantityPerUnit=18 - 500 g pkgs.        UnitPrice=98.0000       UnitsInStock=29         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=17    ProductName=Alice Mutton        SupplierID=7    CategoryID=6    QuantityPerUnit=20 - 1 kg tins  UnitPrice=40.0000       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=28    ProductName=Rössle Sauerkraut   SupplierID=12   CategoryID=7    QuantityPerUnit=25 - 825 g cans         UnitPrice=46.6000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=29    ProductName=Thüringer Rostbratwurst     SupplierID=12   CategoryID=6    QuantityPerUnit=50 bags x 30 sausgs.    UnitPrice=124.7900      UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=42    ProductName=Singaporean Hokkien Fried Mee       SupplierID=20   CategoryID=5    QuantityPerUnit=32 - 1 kg pkgs.         UnitPrice=15.0000       UnitsInStock=26         UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }
ProductID=53    ProductName=Perth Pasties       SupplierID=24   CategoryID=6    QuantityPerUnit=48 pieces       UnitPrice=33.8000       UnitsInStock=0  UnitsOnOrder=0  ReorderLevel=0  Discontinued=True       Order_Details=...       Category={ }    Supplier={ }


First - Simple

This sample uses First to select the first Shipper in the table.

Public Sub LinqToSqlWhere06()
    Dim shipper As Shipper = db.Shippers.First()

    ObjectDumper.Write(shipper, 0)
End Sub

Result:
ShipperID=1     CompanyName=Speedy Express      Phone=(503) 555-9831    Orders=...


First - Element

This sample uses Take to select the first Customer with CustomerID 'BONAP'.

Public Sub LinqToSqlWhere07()
    Dim cust = From c In db.Customers _
        Where c.CustomerID = "BONAP" Take 1

    ObjectDumper.Write(cust, 0)
End Sub

Result:
CustomerID=BONAP        CompanyName=Bon app'    ContactName=Laurence Lebihan    ContactTitle=Owner      Address=12, rue des Bouchers    City=Marseille  Region=null     PostalCode=13008        Country=France  Phone=91.24.45.40       Fax=91.24.45.41         Orders=...      CustomerCustomerDemos=...


First - Condition

This sample uses First to select an Order with freight greater than 10.00.

Public Sub LinqToSqlWhere08()
    Dim ord = (From o In db.Orders _
        Where o.Freight > 10D _
        Select o).First()

    ObjectDumper.Write(ord, 0)
End Sub

Result:
OrderID=10248   CustomerID=VINET        EmployeeID=5    OrderDate=7/4/1996      RequiredDate=8/1/1996   ShippedDate=7/16/1996   ShipVia=3       Freight=32.3800         ShipName=Vins et alcools Chevalier      ShipAddress=59 rue de l'Abbaye  ShipCity=Reims  ShipRegion=null         ShipPostalCode=51100    ShipCountry=France      Order_Details=...       Employee={ }    Customer={ }    Shipper={ }