views:

99

answers:

1

With RIA services, I have a Contract that has a list of Orders (1 to many relationship). Given a Contract, is there an easy way to load all of its orders? Currently, I am creating a method on the service that takes a ContractKey and returns a query that selects all Orders on that ContractKey, and I pass that query to the Context.Load method. Is there was a built in way to do something like

Context.Load(myContract.Orders);
A: 

I think the way you are doing it (seperate query for orders by ContractKey) is probably the best approach. You can also use Include operator on your query to include the orders as demonstrated by Brada here.

public IQueryable<SuperEmployee> GetSuperEmployees()
{        
  return this.Context.SuperEmployeeSet               
         .Include("Quotes")               
         .Where(emp=>emp.Issues>10)               
         .OrderBy(emp=>emp.EmployeeID);
}

You can also serialize them for sending them back down the wire by using the Include attribute on your class.

Bryant