Data Access has been discontinued. Please refer to this page for more information.

How to: Filter Data

This topic shows how to filter query results. The example returns a collection of OrderDatail objects that represent all orders with UnitPrice more than 15.00.

To run the code in this example, you need a fluent model based on the Northwind database.

The following code is the LINQ example.

using ( FluentModel dbContext = new FluentModel() )
   var query = from orderDetail in dbContext.OrderDetails
               where orderDetail.UnitPrice > 15
               select new
   foreach ( var item in query )
       Console.WriteLine( "ProductName: {0}, UnitPrice: {1}",
           item.ProductName, item.UnitPrice );
Using dbContext As New FluentModel()
 Dim query = From orderDetail In dbContext.OrderDetails
             Where orderDetail.UnitPrice > 15
             Select New With {Key orderDetail.UnitPrice, Key orderDetail.Product.ProductName}
 For Each item In query
  Console.WriteLine("ProductName: {0}, UnitPrice: {1}", item.ProductName, item.UnitPrice)
 Next item
End Using

See Also