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 8379947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:19:30+00:00 2026-06-09T16:19:30+00:00

Consider the following (simplified) domain model stored in RavenDB: public abstract class PriceCalculation {

  • 0

Consider the following (simplified) domain model stored in RavenDB:

public abstract class PriceCalculation
{
 // omitted for brevity
}

public class CostBasedPriceCalculation : PriceCalculation
{
 public decimal Margin { get; private set; }
}

public class FixedPriceCalculation : PriceCalculation
{
 public decimal FixedPrice { get; private set; }
}

public class ProductPricingStrategy
{
 public string ProductId { get; private set; }
 public PriceCalculation PriceCalculation { get; private set; }
}

The stored entity is ProductPricingStrategy and I would like to be able to query the collection by price calculation type as well as price calculation specific variables. For example, I would like to get the set of all product pricing strategies having a cost based price calculation with margin less than 0.2. In other words, I would like to be able to query the following projection:

public class FlattenedProductPricingStrategy
{
  public string PriceCalculationType { get; set; }
  public decimal? FixedPrice { get; set; }
  public decimal? Margin { get; set; }
}

The brute force approach would be to store a flattened class hierarchy more closely matching the projection instead of the domain object model directly. Upon retrieval from and persistence to RavenDB the flattened object would be mapped to the domain object. I’ve considered using an intermediate object for other reasons, such as being able to handle all serialization concerns in the mapped class as well as having a buffer zone for re-factoring, however I’ve been steered away from it. Is there a way to avoid this intermediate object and create an index based on the original object model directly?

  • 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-09T16:19:31+00:00Added an answer on June 9, 2026 at 4:19 pm

    You need to define an index like this:

    from s in docs.ProductPricingStrategy
    select new
    {
      s.PriceCalculation.Margin,
      s.PriceCalculation.FixedPrice
    }
    

    And then just query it normally.

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

Sidebar

Related Questions

Let's consider the following simplified Resource hierarchy: public abstract class Resource { static public
Consider the following simplified objects and relationships: public class Job{ int JobId; String name;
Consider the following (simplified) example: abstract class Bar[T] { val f: PartialFunction[T, T] val
Consider the (highly simplified) following case: class Dispatcher { public: receive() {/*implementation*/}; // callback
Consider the following class (simplified in order to focus in the core problem): public
consider the following simplified example: public class Ticket { public int Id; public TicketState
Consider the following simplified demonstration: Class X contain Class Y . Class Y has
Consider following 2 programs giving same error First calss: public class Testing { Testing
Consider the following simplified version of my code. I have a template class A
Consider I have defined the following models: class Tag(models.Model): name = models.CharField(max_length=20) class Entry(models.Model):

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.