You can use the Projections function for RavenDB to convert.
It just changes the shape of the Json document after RavenDB pulled it out of the doc repository, so the fields should not be marked as Stored for it to work
public PostsForList() { Map = posts => from post in posts select new { Id = post.Id, Title = post.Title, CommentsCount = post.Comments, }; TransformResults = (database, posts) => from post in posts select new { post.Id, post.Title, post.CommentsCount }; }
You still need .As<new type> when querying this index, otherwise RavenDB will complain. Something like that:
session.Query<Post, PostTitleCommentsCount>() .Where(x => x.Title == "blah") .As<PostTitleCommentsCount>() .ToList();
It is most often used for combining, see this blog post for more information, but it works in this scenario.
source share