title: OData / WCF Data Service not working with complex type
body: <p>I'm brand new to OData and WCF data services so this might be an easy problem. I'm using VS Web Developer Express 2010 where I have a very simple WCF Data Service hosted in a console app. It's returning an IQuerable collection of a simple 'Study' class from a repository (located in a separated dll project), which in turn retrieves 'Study' classes from a db project in another dll (so 3 projects in the solution). </p>
  
  <p>I also have an 'Experiment' class in the db project and there can be multiple Experiments in a Study. When I exclude the Experiment class from the Study everything works and I get data coming back. The problem happens when I add a List collection to the Study class, then I get a runtime error when I try to run the service. In Firebug the error is '500 Internal Server Error', and the message in the browser is 'Request Error. The server encountered an error processing the request. See server logs for more details.'</p>
  
  <p>I have IIS 7 and I also just installed IIS 7.5 but again it's brand new to me, so I can't figure out where the service is hosted or where to view the server / web logs. There are only IIS 7 logs visible in 'C:\inetpub\logs\LogFiles\W3SVC1'. The VS web server (Cassini) doesn't start when I run the app, so this suggests it's being hosted in IIS 7.5 (?). </p>
  
  <p>So<br>
   - how do I return child classes / complex objects?<br>
   - how do I know where my service is hosted and where can I find the server logs?</p>
  
  <p>Here's the host app:</p>
  
  <pre><code>using MyStudyRepository;
  using MyStudyDB;
  
  namespace MyStudyService
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              string serviceAddress = "http://localhost:998";
              Uri[] uriArray = { new Uri(serviceAddress) };
              Type serviceType = typeof(StudyDataService);
  
              using (var host = new DataServiceHost(serviceType,uriArray))
              {
                  host.Open();
                  Console.WriteLine("Press any key to stop service");
                  Console.ReadKey();
              }
          }
      }
  
      public class StudyDataService : DataService&lt;StudyRepository&gt;
      {
          public static void InitializeService(IDataServiceConfiguration config)
          {
              config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
          }
      }
  }
  </code></pre>
  
  <p>Here's the repository:</p>
  
  <pre><code>using MyStudyDB;
  
  namespace MyStudyRepository
  {
      public class StudyRepository
      {
          List&lt;Study&gt; _List = new List&lt;Study&gt;();
  
          //Add constructor to populate myStudies list on creation of class
          public StudyRepository()
          {
              for (int i = 1; i &lt; 5; i++)
              {
                  Study myStudy = new Study() { ID = i, StudyOwnerId = i, StudyName = "Study" + i.ToString() /*, Experiments = null */ };
                  _List.Add(myStudy);
              }
          }
  
          public IQueryable&lt;Study&gt; Studies
          {
              get
              {
                  return _List.AsQueryable&lt;Study&gt;();
              }
          }
      }
  }
  </code></pre>
  
  <p>And here's the DB:</p>
  
  <pre><code>namespace MyStudyDB
  {
      public class Study
      {
          public int ID { get; set;}
          public int StudyOwnerId { get; set; }
          public string StudyName { get; set; }
          //public List&lt;Experiment&gt; Experiments { get; set; }
      }
  
      public class Experiment
      {
          public int ID { get; set; }
          public string Name { get; set; }
          public int StudyId { get; set; }
      }
  }
  </code></pre>