Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Projecting to a complex type



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 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.


var result = client.Search()
.Select(x => new SearchResult { 
Code = x.Code, 
Boxes= x.Platforms.Select(
y => new Box
                Id= y.Id,

                Name = y.Name


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



Edited, Dec 06, 2016 12:06


You have to create an anonyme object, and then create your object from that when you get the result back. 

Edited, Dec 06, 2016 23:00

Hi Jonas,

thanks for your reply.  I've tried using an anonymous type, but the entire Platforms still gets transfered over the wire instead of the individual fields.

e.g. when using anonymous type the request for the projection looks like this:




Dec 07, 2016 10:45
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.