Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:03:12+00:00 2026-06-12T16:03:12+00:00

I’m trying to use the TransformResults feature, and I can’t get it to work.

  • 0

I’m trying to use the TransformResults feature, and I can’t get it to work. I’m not totally sure I understand this feature, perhaps there is another way to solve this problem. What I want is just the Id from the Order and the email addesses from the Customer and the Entrepreneur. I am happy for all tips that can take me in the right direction. Here is my code.

Document

public class OrderDocument

    public string Id {get; set }

    public EntrepreneurInfo EntrepreneurInfo { get; set; }

    public CustomerInfo CustomerInfo { get; set; }

    public OrderStatus CurrentOrderStatus { get; set; }
}

Info classes

public class EntrepreneurInfo
{
    public string EntrepreneurDocumentId { get; set; }

    public string Number { get; set; }

    public string Name { get; set; }
}

public class CustomerInfo
{
    public string CustomerDocumentId { get; set; }

    public string Number { get; set; }

    public string Name { get; set; }
}

The info classes are just subsets of a Customer and Entrepreneur documents respectively.
The Customer and Entrepreneur documents inherits from a base class ( AbstractOrganizationDocument) that has the EmailAddress property.

My Index

public class OrdersApprovedBroadcastingData : 
    AbstractIndexCreationTask<OrderDocument, OrdersApprovedBroadcastingData.ReduceResult>
{
    public OrdersApprovedBroadcastingData()
    {
        this.Map = docs => from d in docs 
                           where d.CurrentOrderStatus == OrderStatus.Approved 
                            select new
                            {
                                Id = d.Id,
                                CustomerId = d.CustomerInfo.CustomerDocumentId,
                                EntrepreneurId = d.EntrepreneurInfo.EntrepreneurDocumentId
                            };

        this.TransformResults = (db, orders) => from o in orders
                let customer = db.Load<CustomerDocument>(o.CustomerId)
                let entrepreneur = db.Load<EntrepreneurDocument>(o.EntrepreneurId)
                select
                    new 
                        {
                            o.Id,
                            o.CustomerId,
                            CustomerEmail = customer.EmailAddress,
                            o.EntrepreneurId,
                            EntrepreneurEmail = entrepreneur.EmailAddress
                        };
    }

    public class ReduceResult
    {
        public string Id { get; set; }

        public string CustomerId { get; set; }

        public string CustomerEmail { get; set; }

        public string EntrepreneurId { get; set; }

        public string EntrepreneurEmail { get; set; }
    }
}

If I look at the result of this Index in Raven Studio I get null values for all fields except the Id. And finally here is my query.

Query

        var items =
            this.documentSession.Query<OrdersApprovedBroadcastingData.ReduceResult, OrdersApprovedBroadcastingData>()
                .Select(x => new OrdersToBroadcastListItem
                    {
                        Id = x.Id,
                        CustomerEmailAddress = x.CustomerEmail,
                        EntrepreneurEmailAddress = x.EntrepreneurEmail
                    }).ToList();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:03:13+00:00Added an answer on June 12, 2026 at 4:03 pm

    Change your index to:

    public class OrdersApprovedBroadcastingData : AbstractIndexCreationTask<OrderDocument>
    {
      public OrdersApprovedBroadcastingData()
      {
        Map = docs => from d in docs
                      where d.CurrentOrderStatus == OrderStatus.Approved
                      select new
                      {
                      };
    
        TransformResults = (db, orders) =>
          from o in orders
          let customer = db.Load<CustomerDocument>(o.CustomerInfo.CustomerDocumentId)
          let entrepreneur = db.Load<EntrepreneurDocument>(o.EntrepreneurInfo.EntrepreneurDocumentId)
          select new
            {
              o.Id,
              CustomerEmailAddress = customer.EmailAddress,
              EntrepreneurEmailAddress = entrepreneur.EmailAddress
            };
      }
    }
    

    Your result class can simply be the final form of the projection, you don’t need the intermediate step:

    public class Result
    {
      public string Id { get; set; }
      public string CustomerEmailAddress { get; set; }
      public string EntrepreneurEmailAddress { get; set; }
    }
    

    You don’t have to nest this class in the index if you don’t want to. It doesn’t matter either way. You can query either with:

    var items = session.Query<Result, OrdersApprovedBroadcastingData>();
    

    Or with

    var items = session.Query<OrderDocument, OrdersApprovedBroadcastingData>().As<Result>();
    

    Though, with the first way, the convention tends to be to nest the result class, so really it would be

    var items = session.Query<OrderDocument.Result, OrdersApprovedBroadcastingData>();
    

    Note in the index map, I am not including any properties at all. None are required for what you asked. However, if you want to add a Where or OrderBy clause to your query, any fields you might want to filter or sort on should be put in there.

    One last thing – the convention you’re using of OrderDocument, CustomerDocument, EntrepreneurDocument, is a bit strange. The usual convention is just Order, Customer, Entrepreneur. Think of your documents as the persisted form of the entities themselves. The convention you are using will work, it’s just not the one usually used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.