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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:21:36+00:00 2026-06-17T02:21:36+00:00

I have a domain object called Campaign which contains a few string properties and

  • 0

I have a domain object called Campaign which contains a few string properties and a collection of TrackingEntry objects. Whenever I retrieve a query from the document session, this property is empty, even though I have at least one tracking entry saved. How can I approach retrieving the campaign object such that the tracking entry collection is retrieved as well? Here’s the relevant code for the Campaign:

public class Campaign : Entity
{
    private ICollection<TrackingEntry> trackingEntries;

    public string BrandId { get; set; }

    public ICollection<TrackingEntry> TrackingEntries
    {
        get { return trackingEntries ?? (trackingEntries = new Collection<TrackingEntry>()); }
    }
}

The method that has the problem takes in a comma delimited string of brand ids, retrieves all campaigns with those brand ids, loops through and performs some custom logic based on the contents of the tracking entry collection, amongst other things. Here’s the relevant parts:

        var brandIds = input.Split(',');
        var campaigns = session.Query<Campaign>().Where(x => x.BrandId.In(brandIds));
        foreach (var campaign in campaigns)
        {
            DateTime? dateClaimed = null;
            var trackingEntry = campaign.TrackingEntries.FirstOrDefault(x => x.ConsumerId == consumer.Id);
            if (trackingEntry != null)
            {
                dateClaimed = trackingEntry.CreatedOn;
            }
        }

I know that there is one tracking entry but setting a breakpoint shows an empty collection. I thought it might be raven caching and a stale index but the issue is still here 24 hours after writing the record into the database. I’m thinking that I probably need a map-reduce index to deal with that collection but am still very hazy on how they work. Thoughts?

  • 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-17T02:21:38+00:00Added an answer on June 17, 2026 at 2:21 am

    The only problem is in the way you set up your properties. By default, private fields aren’t serialized, and public properties will only deserialize if you have a setter defined. The setter itself can be public or private. If you’re concerned about initializing your list, just do it in the constructor.

    Here is the most simple approach:

    public class Campaign : Entity
    {
        public Campaign()
        {
            TrackingEntries = new Collection<TrackingEntry>();
        }
    
        public string BrandId { get; set; }
    
        public ICollection<TrackingEntry> TrackingEntries { get; private set; }
    }
    

    The same would work for any collection type. (array, list, enumerable, etc)

    An alternative approach would be through attributing. But I think the first approach is better because it keeps your entities free of dependencies, and is easier to read.

    public class Campaign : Entity
    {
        [JsonProperty("TrackingEntries")]
        private ICollection<TrackingEntry> trackingEntries;
    
        public string BrandId { get; set; }
    
        [JsonIgnore]
        public ICollection<TrackingEntry> TrackingEntries
        {
            get { return trackingEntries ?? (trackingEntries = new Collection<TrackingEntry>()); }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this huge domain object(say parent) which contains other domain objects. It takes
I have a an object stored in the model called domain, which has two
I have a domain object called User . Properties of user include ssoId, name,
I have a domain model object which has properties of type System.DateTimeOffset. I'm using
We have a custom object in Salesforce called domain which reflects each website we
I have a hibernate object called User which has a many-to-many relationship with another
We have several domain objects which need to support both read-only and read-write modes;
I have a Domain object called User and UserCreateViewModel.Automapper is used for mapping from
Following is the scenario. I have something called as Domain which can have multiple
I have a domain class called FoapRequest. I want one of the properties called

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.