0

我有两个类,客户端和用户。用户是客户端中的一个字段(有一个外键)。我正在尝试加入,获取所有客户和相关用户(这是一对一的)。

我正在使用实体框架和一个为我提供数据的 Web 服务。

我目前正在让我的所有客户喜欢:

public DbSet<Client> getClients()
{
    return context.Clients;
}

我还需要获取相关对象用户。我找到了一个告诉我这样做的例子:

public DbSet<Client> getClients()
{
    return context.Clients.include(x => x.User);
}

这会引发异常,我需要使用 IQueryable。如果我更改我的功能,与 Web 服务的连接将不起作用。

我该如何做我想做的事?

编辑:

我从网络服务得到的例外是An error occurred while receiving the HTTP response to http://localhost:60148/WebService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

4

1 回答 1

1

试试这些链接: Expose IQueryable Over WCF ServiceIQueryable 问题使用 WCF 你需要发回其他东西,比如一个列表,因为 IQueryable 实际上是一个查询,你不能发回。上面的链接提供了替代方法来解决 IQueryable 限制。

于 2014-04-03T13:00:39.033 回答