0

I created a wcf service but it doesn't work with an entity object. I tested it with List<String> and it worked but it doesn't work with an entity.

I have this message :

The HTTP request to 'http://localhost:26823/test/Service.svc' has exceeded the allotted timeout of 00:00:59.9950000. The time allotted to this operation may have been a portion of a longer timeout.

This my code :

[ServiceContract]
public interface IService
{
    [OperationContract]
    List<Contrat> GetData(int value);

}

and

public List<Contrat> GetData(int value)
{
    contratsDispo = (MYLINQ).ToList();

    return contratsDispo;
}

I have my data here. I looked here.

My code for windows phone :

    private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
    {
        ServiceClient client = new ServiceClient();
        client.GetDataAsync(1);

        client.GetDataCompleted +=new EventHandler<GetDataCompletedEventArgs>(client_GetDataCompleted);
    }

    void client_GetDataCompleted(object sender, GetDataCompletedEventArgs e)
    {
        if (e.Result != null)
        {
         ....
        }
    }

thx for your help

  • Check this: http://stackoverflow.com/questions/5996490/problem-with-wcf-ef-4-1-lazy-loading/5996648#5996648 and linked answers, perhaps it will help you – Ladislav Mrnka May 14 '11 at 08:40

1 Answers1

0

If you run a profiler on the database in the two cases you will see what is causing the problem.

Actually I think that the comment of Ladislav points to the problem:

  • When you do the ToList it just converts the top level of the object to a list
  • When you return the object it tries to load all sub objects

It is the WCF serializer that triggers the loading of the sub entities.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252