0

I have two classes, client and user. User is a field in client (there is a foreign key). I am trying to do a join, getting all the clients and the related user (it is one to one).

I am using Entity Framework and a web service that gives me my data.

I currently am getting all my clients like:

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

I need to also get the related object user. I found an example that tells me to do:

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

This throws an exception, I need to be working with IQueryable. If I change my function the connection to the web service does not work.

How do I do what I am trying to do?

EDIT:

The exception I get from the webservice is 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.

Meir
  • 1,943
  • 5
  • 22
  • 38
  • what is the exception? – Paritosh Apr 02 '14 at 17:48
  • It could not connect to my webservice over http. I can give you the exact exception in am hour... – Meir Apr 02 '14 at 17:50
  • @Paritosh I added the exception I got to the question. – Meir Apr 02 '14 at 18:23
  • Are you returning a DbSet from the wcf service? I don't think that's possible, could be wrong. Because if you are passing if over the wcf service, IQueryable will not work, as that's passing a query while wcf service needs to return just the data. You could try creating a custom object (ClientBasic) have that contain a User field, when you get the data in your service, populate a List of ClientBasic with what you need an return that. – Paritosh Apr 02 '14 at 19:40
  • Also it looks like there are work arounds, try these links: http://stackoverflow.com/questions/4291370/expose-iqueryable-over-wcf-service and http://stackoverflow.com/questions/3341469/iqueryable-problems-using-wcf – Paritosh Apr 02 '14 at 19:40
  • The links you sent me helped a lot. If you like, you can write an explanation up in an answer so that I can give you the credit you deserve (and the upvote ;-)) – Meir Apr 02 '14 at 20:05

1 Answers1

1

try these links: Expose IQueryable Over WCF Service and IQueryable problems using WCF you need to send something else back, like a List, as IQueryable is actually a query, which you can't send back. the links above provide alternative ways to do it, to get around the IQueryable restriction.

Community
  • 1
  • 1
Paritosh
  • 4,243
  • 7
  • 47
  • 80