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

How to: Filter Data

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

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 to create a new Telerik Data Access Domain Model based on the Northwind database.

The following code is the LINQ example.

using ( EntitiesModel dbContext = new EntitiesModel() )
{
   var query = from orderDetail in dbContext.OrderDetails
               where orderDetail.UnitPrice > 15
               select new
               {
                   orderDetail.UnitPrice,
                   orderDetail.Product.ProductName
               };
   foreach ( var item in query )
   {
       Console.WriteLine( "ProductName: {0}, UnitPrice: {1}",
           item.ProductName, item.UnitPrice );
   }
}
Using dbContext As New EntitiesModel()
 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