Telerik OpenAccess ORM

Telerik OpenAccess ORM Send comments on this topic.
How to: Filter Data
See Also
Programmer's Guide > Feature Reference > API > LINQ Guide > How to: Filter Data

Glossary Item Box

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 OpenAccess Domain Model based on the Northwind database.

The following code is the LINQ example.

C# Copy Code
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 );
   }
}
VB.NET Copy Code
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