简体   繁体   English

如何加载与RIA Services相关的所有项目?

[英]How do I load all items in a relationship with RIA Services?

With RIA services, I have a Contract that has a list of Orders (1 to many relationship). 使用RIA服务时,我有一个包含订单列表(1对多关系)的合同。 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. 当前,我正在服务上创建一个使用ContractKey并返回查询的方法,该查询选择该ContractKey上的所有订单,并将该查询传递给Context.Load方法。 Is there was a built in way to do something like 是否有一种内置的方式来做类似的事情

Context.Load(myContract.Orders);

I think the way you are doing it (seperate query for orders by ContractKey) is probably the best approach. 我认为您的做法(按ContractKey分别查询订单)可能是最好的方法。 You can also use Include operator on your query to include the orders as demonstrated by Brada here . 您还可以在查询中使用Include运算符,以包含Brada此处演示的订单。

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. 您还可以使用类上的Include属性来序列化它们,以将它们发送回网络。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM