title: StackOverflowException trying to return a Linq query result as a List through a WCF Service
body: <p>I have had a lot of problems with this stuff and I can't solve it even with a simpler example.</p>
  
  <p>I've a WCF service that returns a list of objects (from my Entity Model).</p>
  
  <p>The model only has 2 tables:
  Person, with id, name and office_id (foreign key)
  and Office, with id and address</p>
  
  <p>I'm making a really simple linq query that returns the first of these people. This is working ok, even the "ToList()" method works ok.</p>
  
  <p>The problem is that when I try to return it through the service it crashes with a "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"</p>
  
  <p>I think it's related to the Navigation Properties when it tries to serialize the Person object. These Navigation Properties appear in both the Person and Office model, the Person table has a "Office" Navigation Property, but Office table has a "Person" Navigation Property too!!</p>
  
  <p>I think these navigation properties can be useful for other scenarios but I can't find a way to say not to load those contents or at least not to serialize and return it through the service!!</p>
  
  <p>This is the linq query (this works, the list really has one person inside):</p>
  
  <pre><code>var query = (from chosen in entities.person
              select chosen).First&lt;person&gt;();
  
  return query.ToList&lt;person&gt;();
  </code></pre>
  
  <p>Does anybody has ever seen something like this? I have had several WCF-Linq projects before and I never had any similar issue.</p>
  
  <p>Thanks in advance.</p>