ayende/ravendb — pull request #304 by eulerfx (2013-04-03 22:31:47+00:00)
Title: Pass type information, when available, for includes.

Addresses issue described [on the mailing list](https://groups.google.com/forum/#!topic/ravendb/Q8frTaSf0uc):

Raven throws `InvalidCastException` when loading a document under the specified conditions:
- The document has no `Raven-Clr-Type` metadata. In this case it was due to it being imported via CSV.
- The document was loaded via `Include` from a referencing document.

The exception details:

>System.InvalidCastException: Unable to cast object of type 'Raven.Abstractions.Linq.DynamicJsonObject' to type '...'.
> at Raven.Client.Document.DocumentSession.Load[T](String id)

This does not happen when loading the same document directly. It seems that the type information from `TInclude` isn't being passed on.

One concern I have with this PR is the ordering of include results. Currently, the code in `MultiLoadOperation.Complete` assumes that the include results are in the same order as they were requested. This assumption is used to map each included result to the corresponding type.