-
Notifications
You must be signed in to change notification settings - Fork 5
Creating executing multiple join queries
ErnestoDeLucia edited this page Oct 8, 2016
·
1 revision
Working with multiple join queries, requires a two step process. First, one must get the query object needed: Select, Update or Delete. Second one must execute the query.
Using the test database, one can select the orders coming from customers of a particular city:
var store = new EntityStore(_dbConnection);
var selectQuery = store.GetSelectQuery<Order>()
.JoinOn<Customer>((o, c) => o.CustomerId == c.Id)
.Where<Order, Customer>((o, c) => c.City == "Gainesville");
var customerOrders = store.ExecuteQuery<Order, Customer, CustomerOrder>(selectQuery);
The selectQuery is a single join query with filter criteria in the where clause. The next step is to execute the query. In this case, the resulting type is 'CustomerOrder' which maps fields from both types that participate in the join: Customer and Order.