Telerik OpenAccess ORM

Telerik OpenAccess ORM Send comments on this topic.
How to: Execute a Parameterized Query
See Also
Programmer's Guide > Feature Reference > API > LINQ Guide > How to: Execute a Parameterized Query

Glossary Item Box

This topic shows how to execute a LINQ query with parameters by using OpenAccessContext. The example passes one parameter, executes the query, and iterates through the collection of Customer items.

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())
{
   IQueryable<Customer> customersQuery = from customer
in dbContext.Customers
                                           where customer.Country ==
"Germany"
                                           
select customer;
   Console.WriteLine(
"Customer IDs: ");
   
foreach (var item in customersQuery)
   {
       Console.WriteLine(item.CustomerID);
   }
}
VB.NET Copy Code
Using dbContext As New EntitiesModel()
 Dim customersQuery As IQueryable(Of Customer) = From customer In dbContext.Customers
                                                 Where customer.Country = "Germany"
                                                 Select customer
 Console.WriteLine("Customer IDs: ")
 For Each item In customersQuery
  Console.WriteLine(item.CustomerID)
 Next item
End Using

See Also