How to: Execute a Parameterized Query

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

The following code is the LINQ example.

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)
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
 Next item
End Using

See Also