title: 504 with big resultset in RIA Domain Service
body: <p>I am building a RIA Domain Service that needs to perform queries on a table with lots of data. 
  By working on this, I've realized the table size can effectively be an issue.</p>
  
  <p>For example:</p>
  
  <pre><code>return this.ObjectContext.Logs;
  </code></pre>
  
  <p>fails with a 504 err, whereas:</p>
  
  <pre><code>return this.ObjectContext.Logs.Take(10);
  </code></pre>
  
  <p>works. </p>
  
  <p>As you can see I am working on a table of logs, which includes a field "username". I need to retrieve all distinct usernames from the table. So I set up this method:</p>
  
  <pre><code>public IEnumerable&lt;string&gt; GetUsers()
      {
          var users = (from l in this.ObjectContext.Logs
                      select l.Username).Distinct().Take(10);
  
          return users;
      }
  </code></pre>
  
  <p>I am trying to execute all the necessary operations on the server-side, in order to reduce the transferred information (and relative delay) to the minimum. </p>
  
  <p>However, even with that query I get a 504 error. In Fiddler I see: "ReadResponse() failed: The server did not return a response for this request."</p>
  
  <p>Initially I thought this to be a transport issue (perhaps the size of the transferred data was too big or so), so I set up a breakpoint on "return users". I ran the code and the debugger stopped on the "return users" line. I clicked on "results view" but at that point it was unable to display any result, just showing an error.</p>
  
  <p>I'd like to report here the error, but suddenly Visual Studio does not stop anymore on the DomainService breakpoints and stops only on the Silverlight project's ones. I am actually investigating this as it seems that it is not calling the domain service anymore (fiddler does not show any call to the ria domain service anymore).</p>
  
  <p>Is there anybody who can assist me in solving these issues? I am really struggling in getting this to work.</p>
  
  <p>Thanks in advance,
  Cheers,
  Gianluca</p>