ravendb/ravendb — pull request #444 by ArnoldZokas (2012-01-21 15:11:58+00:00)
Title: Added a failing test to demonstrate failing ad hoc projection

Given domain model...

``` c#
public class Entity
{
public int Id { get; set; }
public Category Category { get; set; }
}

public class Category
{
public string Title { get; set; }
}
```
... I want to project results of a select query to this view model:

``` c#
public class EntityViewModel
{
public int Id { get; set; }
public string CategoryTitle { get; set; }
}
```
I have tried the following query:

``` c#
var viewModel = (from entity in _documentSession.Query()
select new EntityViewModel
{
Id = entity.Id,
CategoryTitle = entity.Category.Title
}.ToList();
```
The result of this is only partially correct: the Id is set, the CategoryTitle is not.

Is this behaviour by design? Is there, perhaps, an API call I should use for this?

I posted a question on StackOverflow (http://stackoverflow.com/questions/8950182/how-to-handle-projections-in-ravendb), but no answers so far.