Quantcast
Viewing all articles
Browse latest Browse all 6894

Projecting to a complex type

Hi,

I would like to project from a nested list to a list of complex classes in Find. The projection code compiles and everything seems to work.

But when I examine the response directly from Find, the entire object is returned from Find instead of the individual fields.

Assuming the Game class gets indexed:

public class Game
{
public string Code;
public List<Platform> Platforms; //nested
}
public class Platform
{
public int Id;
public string Name;
public decimal Cost;
public DateTime ReleaseDate;
}

I would like to project only the "Code" from Game and the "Id" and "Name" from Platform.

e.g.

var result = client.Search<Game>()
.Select(x => new SearchResult { 
Code = x.Code, 
Boxes= x.Platforms.Select(
y => new Box              {                Id= y.Id,                Name = y.Name               }),
})
.GetResult();

From the documentation its probably a limitation. But does anyone know if the above is possible in another way?

Thanks,

Danie


Viewing all articles
Browse latest Browse all 6894

Trending Articles