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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:18:48+00:00 2026-05-23T14:18:48+00:00

I have an aggregate named Campaigns every with a root entity named campaign, this

  • 0

I have an aggregate named Campaigns every with a root entity named campaign, this root entity has a list of attempts (entity)

    public class Attempts: IEntity<Attempts>
    {
        private int id;
        public AttempNumber AttemptNumber {get;}
        //other fields 
    }

    public class Campaign: IEntity<Campaign> //root
    {
        private int id;
        public IList<Attempt> {get;}
        //other fields 
    }

Im using a method to add a campaign attempt

 public virtual void AssignAttempts(Attempts att)
        {
            Validate.NotNull(att, "attemps are required for assignment");

            this.attempts.add(att);
        }

Problem comes when i try to edit a specific item in attempts list. I get Attempt by AttempNumber and pass it to editAttempt method but i dont know how to set the attempt without deleting whole list and recreate it again

 public virtual void EditAttempts(Attempts att)
 {
        Validate.NotNull(att, "attemps are required for assignment");
 }

Any help will be appreciated!

Thanks,
Pedro de la Cruz

  • 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-05-23T14:18:48+00:00Added an answer on May 23, 2026 at 2:18 pm

    First, I think there may be a slight problem with your domain model. It seems to me like ‘Campaign’ should be an aggregate root entity having a collection of ‘Attempt’ value objects (or entities). There is no ‘Campaigns’ aggregate unless you have a parent concept to a campaign which would contain a collection of campaigns. Also, there is no ‘Attempts’ entity. Instead a collection of ‘Attempt’ entities or values on the ‘Campaign’ entity. ‘Attempt’ may be an entity if it has identity outside of a ‘Campaign’, otherwise it is a value object. The code could be something like this:

    class Campaign {
        
        public string Id { get; set; }
        
        public ICollection<Attempt> Attempts { get; private set; }
        
        public Attempt GetAttempt(string id) {
            return this.Attempts.FirstOrDefault(x => x.Number == id);
        } 
        
    }
        
    class Attempt {
        public string Number { get; set; }
        public string Attribute1 { get; set; }
    }
    

    If you retrieve an Attempt from the Campaign entity and then change some of the properties, you should not have to insert it back into the campaign entity, it is already there. This is how the code would look if you were using NHibernate (similar for other ORMs):

    var campaign = this.Session.Get<Campaign>("some-id");
        
    var attempt = campaign.GetAttempt("some-attempt-id");
        
    attempt.Attribute1 = "some new value";
        
    this.Session.Flush(); // will commit changes made to Attempt 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made an aggregate class named Question . This contains references to Answer
I have Person class which is root of its aggregate, this aggregate also contains
I have a simple 1:many aggregate relationship, lets say: public class Parent { public
VB.NET .NET 3.5 I have an aggregate class called Package as part of a
I'm doing this query: SomeObject.objects.annotate(something=Avg('something')).order_by(something).all() I normally have an aggregate field in my model
I have a domain Aggregate, call it Order that contains a List of OrderLines.
I have a class TContainer that is an aggregate of several stl collections pointers
I have a class which models online campaigns i.e. people clicking through to the
I have one class named Question and another named StudentDriver . StudentDriver have a
I have some basic classes with cloning methods: public class SimpleClass { public int

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.