ravendb/ravendb — pull request #527 by aknuds1 (2013-08-09 20:24:19+00:00)
Title: Add test for Load/Include<T, TInclude> referring via Id property

We found in our project that Including other documents via a loaded document's Id property fails silently on the server. Let's say we have the following types:

class Customer {
public int Id { get; set; }
}

class Order {
public int Id { get; set; }
}

If we load an Order as follows:

session.Include(x => x.Id).Load(1);

Then customers/1 will not be included in the response from the server, for reasons unknown. No error is raised, the Include simply has no effect.

I've added a test to check this scenario; it fails, which corresponds to our findings. Regardless of how Raven is supposed to behave in this scenario, I think it'd be good to define it via a test. Personally I'd prefer that this scenario either works or fails with an exception so the client (e.g. our project) isn't left in the dark.